Describe my issue, i have modularization project so will be have different pubspec.yaml, every pubspec i use package for testing :
mockito: ^5.0.8
build_runner: ^2.0.4
dependency_overrides:
analyzer: ^1.7.0
so after generate flutter pub run build_runner build --delete-conflicting-outputs i get issue's, then i search google i it this cause analyzer, then i follow step to change analyze version, still error, in this error :
(base) dendimuhmd#macbook-pro datasources % flutter pub run build_runner build
Changing current working directory to: /Users/dendimuhmd/Documents/dev/flutter/dicoding/creative-movie/core
Failed to build build_runner:build_runner:
../../../../../../.pub-cache/hosted/pub.dartlang.org/build_resolvers-2.0.6/lib/src/resolver.dart:18:8: Error: Error when reading '../../../../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.7.2/lib/src/clients/build_resolvers/build_resolvers.dart': No such file or directory
import 'package:analyzer/src/clients/build_resolvers/build_resolvers.dart';
^
../../../../../../.pub-cache/hosted/pub.dartlang.org/build_resolvers-2.0.6/lib/src/analysis_driver.dart:9:8: Error: Error when reading '../../../../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.7.2/lib/src/clients/build_resolvers/build_resolvers.dart': No such file or directory
import 'package:analyzer/src/clients/build_resolvers/build_resolvers.dart';
^
../../../../../../.pub-cache/hosted/pub.dartlang.org/build_resolvers-2.0.6/lib/src/build_asset_uri_resolver.dart:11:8: Error: Error when reading '../../../../../../.pub-cache/hosted/pub.dartlang.org/analyzer-1.7.2/lib/src/clients/build_resolvers/build_resolvers.dart': No such file or directory
import 'package:analyzer/src/clients/build_resolvers/build_resolvers.dart';......
what is issue with analyzer, it this cause analyzer or?
Modularization structure
Related
flutter run build_runner build - return the following result
Target file "build_runner" not found.
This is supposed to generate model classes from schema, but stuck in the above listed issues.
The issue is with the package dependencies. Executing this flutter pub upgrade --major-versions will solve this issue.
I have the following file structure in my flutter project
lib
- router
-- router.gr
plugins
- myplugin //is a dart package
-- input_folder
--- swagger.json
-- lib
--- swagger_generated_code
--- myplugin.dart
-- build.yml
and I use the following packages
https://pub.dev/packages/auto_route
the router.gr is related to the auto_route package
https://pub.dev/packages/swagger_dart_code_generator
and the plugin is related to the swagger_dart_code_generator packge
The plugin has this build.yml from plugins/myplugin/build.yml
targets:
$default:
sources:
- lib/**
- input_folder/**
builders:
chopper_generator:
options:
header: "//Generated code"
swagger_dart_code_generator:
options:
input_folder: "input_folder/"
output_folder: "lib/swagger_generated_code/"
But what ends up happening is that I run
flutter packages pub run build_runner build
in my project root to rebuild the router as specified by the auto_route package. Which then gives the following error
FileSystemException: Cannot create file, path = './.dart_tool' (OS Error: Access is denied.
, errno = 5)
dart:io _File.createSync
package:swagger_dart_code_generator/swagger_dart_code_generator.dart 61:30 _generateExtensions
package:swagger_dart_code_generator/swagger_dart_code_generator.dart 99:32 SwaggerDartCodeGenerator.buildExtensions
package:build_runner_core/src/package_graph/apply_builders.dart 403:33 _validateBuilder
package:build_runner_core/src/package_graph/apply_builders.dart 183:9 new BuilderApplication.forBuilder.<fn>.<fn>
package:build_runner_core/src/package_graph/apply_builders.dart 346:27 _createBuildPhasesForBuilderInCycle.<fn>.<fn>
dart:core Iterable.toList
package:build_runner_core/src/package_graph/apply_builders.dart 293:8 createBuildPhases
package:build_runner_core/src/generate/build_impl.dart 109:29 BuildImpl.create
package:build_runner_core/src/generate/build_runner.dart 34:42 BuildRunner.create
package:build_runner/src/generate/build.dart 109:35 build
package:build_runner/src/entrypoint/build.dart 35:18 BuildCommand._run
package:args/command_runner.dart 209:13 CommandRunner.runCommand
package:build_runner/src/entrypoint/run.dart 26:18 run
.dart_tool\build\entrypoint\build.dart 35:16 main
If I open the plugin folder in a separate window and run the build command in there it works just fine for the plugin.
Is there a way to ignore the plugin folder when rebuilding the router perhaps?
But mainly my question is how can I rebuild my router.gr with my current structure? I can't remove the plugins folder, it needs to stay there as it is.
These are the versions I use
build_runner: ^2.1.8
auto_route_generator: ^3.2.3
chopper_generator: ^4.0.5
json_serializable: ^6.1.4
swagger_dart_code_generator: ^2.4.6
And I am on flutter version 2.10.3
Please share the code where you're initializing AutoRoute.
Meanwhile, this is what I would suggest:
Check if you're not doing anything wrong in the initialization/usage.
Make sure you are using build_runner in dev_dependencies.
Run this command on project root for one-time code generation: flutter pub run build_runner watch
Hi you can execute the buildrunner in a specific folder:
flutter pub run build_runner build lib/ --delete-conflicting-outputs
After I have updated Flutter to v1.22 using code generation with build_runner was not working. I was told that the proper command to use in this version was:
dart pub run build_runner watch --delete-conflicting outputs
However, I receive the following error:
Could not find a file named "pubspec.yaml" in "C:\Users\jpiab\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\_fe_analyzer_shared-2.2.0".
I have no idea why it is looking for pubspec.yaml in that folder, since that folder is not the current working directory.
--- EDIT ---
The file exists in path:
C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-2.2.0
dart is just looking for it in the wrong place. Any ideas on how to fix it?
I solved for me. I use Android Studio in Ubuntu 20.04.01 LTS.
Firstly run this command:
flutter pub get
After run this command:
flutter packages pub run build_runner build
Or:
flutter packages pub run build_runner watch
Source: https://github.com/flutter/flutter/issues/50092
Deleting the .pub-cache folder.
and then run pub get
Edit:
If above method won't work then delete the folder
C:\Users\jpiab\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org_fe_analyzer_shared-2.2.0
and then run pub get from within your project directory.
That same error I had and I resolved it by aligning my dependencies. Check if your build_runner is in the same line as flutter_test if you added it to dev_dependencies.
Error Corrected
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: [latest]
My Error
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: [latest]
I fixed it by changing the environment variable PUB_CACHE to the right folder.
TL;DR
Make sure you run the flutter command from the project's root directory.
As you can see, Running the command from a specific folder reproduces this error while everything works as expected from the project's root directory.
I'm using a package in my project called card_settings and it unfortunately depends on another package called flutter_cupertino_settings. Actually the last one does not support cupertino_icons v1.0.0 an I need to update icons package.
I've tried to use the forked repository by jibiel used to generate the pull request as flutter_cupertino_settings package override but I receive an error that I'm not able to solve:
Running "flutter pub get" in my_app...
Because my_app depends on dependency_overrides from unknown source "flutter_cupertino_settings", version solving failed.
pub get failed (1; Because my_app depends on dependency_overrides from unknown source "flutter_cupertino_settings", version solving failed.)
exit code 1
and this is my dependency override
card_settings: ^1.14.0
dependency_overrides:
flutter_cupertino_settings:
git:
url: https://github.com/jibiel/flutter_cupertino_settings.git
ref: dfb575c82b67ff76d6df240ccda9fefb53596709
Just paste this into your pubspec.yaml file:
card_settings: ^1.14.0
flutter_cupertino_settings: ^0.3.1
cupertino_icons: ^0.1.3
I created an example project inside a my flutter package and inside my example project i did:
dependencies:
flutter:
sdk: flutter
my_package:
path: ../
my_package used rxdart and i received an error after run my example project
Error: Could not resolve the package 'rxdart' in
'package:rxdart/rxdart.dart'.
I ran flutter packages get but the error is still here.
I just ran into the same issue. To solve it follow these steps:
Kill your app if it's running
Run flutter clean in both your main project directory and your my_package directory
Run flutter pub get in both your main project directory and your my_package directory
Now when you build your app you should be all set.
Check first, if you added rxdart package to your pubspec.yaml as shown below:
dependencies:
flutter:
sdk: flutter
rxdart: ^0.24.1
Run flutter pub get