melos
melos copied to clipboard
The pubspec.yaml file has changed since the pubspec.lock file was generated
I'm trying to run the build runner for code generation, the first package succeeds but the other packages fail to run because the pubspec.yaml has changed since the pubspec.lock was generated. Both of those packages depend on the first one (not sure if that matters).
Bootstrap:
➜ flutter_json_schema_form git:(master) ✗ melos bootstrap
melos bootstrap
└> /home/rhalff/development/flutter_json_schema_form
Running "flutter pub get" in workspace packages...
✓ fjsf_theme_material
└> ./packages/fjsf-theme-material
✓ fjsf
└> ./packages/fjsf
✓ flutter_json_schema_form_example
└> ./packages/example
Linking workspace packages...
> SUCCESS
Generating IntelliJ IDE files...
> SUCCESS
-> 3 plugins bootstrapped
Running build_runner in each package directory:
➜ flutter_json_schema_form git:(master) ✗ melos run generate:flutter
melos run generate:flutter
└> melos exec -c 1 --depends-on="build_runner" --flutter -- "flutter pub run build_runner build --delete-conflicting-outputs"
└> RUNNING
$ melos exec
└> flutter pub run build_runner build --delete-conflicting-outputs
└> RUNNING (in 3 packages)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
fjsf:
[INFO] Generating build script...
[INFO] Generating build script completed, took 319ms
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 74ms
[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 558ms
[INFO] Running build...
[INFO] Running build completed, took 19ms
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 53ms
[INFO] Succeeded after 80ms with 0 outputs (0 actions)
fjsf: SUCCESS
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
fjsf_theme_material:
The pubspec.yaml file has changed since the pubspec.lock file was generated, please run "pub get" again.
pub finished with exit code 65
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
flutter_json_schema_form_example:
The pubspec.yaml file has changed since the pubspec.lock file was generated, please run "pub get" again.
pub finished with exit code 65
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$ melos exec
└> flutter pub run build_runner build --delete-conflicting-outputs
└> FAILED (in 2 packages)
└> fjsf_theme_material (with exit code 65)
└> flutter_json_schema_form_example (with exit code 65)
melos run generate:flutter
└> melos exec -c 1 --depends-on="build_runner" --flutter -- "flutter pub run build_runner build --delete-conflicting-outputs"
└> FAILED
➜ flutter_json_schem
Main problem is the pubspec.lock will contain path dependencies of the linked packages: https://github.com/dart-lang/pub/blob/11c2a0978e66fbc2c182dc6a8174db1a3651276c/lib/src/entrypoint.dart#L484-L499
And somehow the check whether those path dependencies are valid will fail.
My current workaround is to comment out the linked dependencies, run melos bootstrap, generate the files, uncomment the linked dependencies and run melos bootstrap again.
I'll see if a PR can be made to the Dart SDK to disable this check when using melos
Hi, I'm also experiencing this issue in monorepo containing 3 packages with build_runner-generated code. Do you have any updates on this issue? Is there any known workaround?
@rrousselGit any update on this?
The fix was merged. But it's likely not available on the Flutter stable channel.
On that note, I will close this, as it was fixed. It's now simply a matter of waiting for the fix to be available to everyone
@rrousselGit Could you link the mentioned PR so we can track when it's available on stable channel?
https://github.com/flutter/flutter/pull/86177
I just tried with the latest dev channel, and it's still not working.
here's my flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, 2.6.0-0.0.pre, on macOS 11.5.1 20G80 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.5.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.59.0)
[✓] Connected device (2 available)
• No issues found!
When I run melos bs
, then try to run flutter pub run build_runner build
in one of my subdirectories, I get:
The pubspec.yaml file has changed since the pubspec.lock file was generated, please run "pub get" again.
pub finished with exit code 65
Could you share your pubspec?
Sure, here's the pubspec I'm running built_runner
on:
name: ferry_test_graphql
version: 0.1.4-dev.3
description: Example GraphQL Operations, used in Ferry tests
repository: https://github.com/gql-dart/ferry
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
gql: ^0.13.0
gql_exec: ^0.3.0
ferry_exec: ^0.1.4-dev.3
built_value: ^8.0.4
built_collection: ^5.0.0
gql_code_builder: ^0.3.0-alpha.0
dev_dependencies:
build_runner: ^2.0.2
gql_build: ^0.3.0-alpha.0
pedantic: ^1.11.0
ferry_generator: ^0.5.0-dev.3
Could you provide the contents of the pubspec.lock
file after melos bs
has been ran - thanks
@Salakar
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "22.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.2"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
build:
dependency: transitive
description:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
build_config:
dependency: transitive
description:
name: build_config
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
build_daemon:
dependency: transitive
description:
name: build_daemon
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
build_resolvers:
dependency: transitive
description:
name: build_resolvers
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
build_runner:
dependency: "direct dev"
description:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
url: "https://pub.dartlang.org"
source: hosted
version: "7.1.0"
built_collection:
dependency: "direct main"
description:
name: built_collection
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.0"
built_value:
dependency: "direct main"
description:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
version: "8.1.2"
built_value_generator:
dependency: transitive
description:
name: built_value_generator
url: "https://pub.dartlang.org"
source: hosted
version: "8.1.1"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
cli_util:
dependency: transitive
description:
name: cli_util
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.3"
code_builder:
dependency: transitive
description:
name: code_builder
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
dart_style:
dependency: transitive
description:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
ferry_exec:
dependency: "direct main"
description:
path: "../ferry_exec"
relative: true
source: path
version: "0.1.4-dev.3"
ferry_generator:
dependency: "direct dev"
description:
path: "../ferry_generator"
relative: true
source: path
version: "0.5.0-dev.3"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.2"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
glob:
dependency: transitive
description:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
gql:
dependency: "direct main"
description:
name: gql
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.0"
gql_build:
dependency: "direct dev"
description:
name: gql_build
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0-alpha.0"
gql_code_builder:
dependency: "direct main"
description:
name: gql_code_builder
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0-alpha.0"
gql_exec:
dependency: "direct main"
description:
name: gql_exec
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
gql_link:
dependency: transitive
description:
name: gql_link
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.0"
graphs:
dependency: transitive
description:
name: graphs
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
io:
dependency: transitive
description:
name: io
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
json_annotation:
dependency: transitive
description:
name: json_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
logging:
dependency: transitive
description:
name: logging
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
mime:
dependency: transitive
description:
name: mime
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
package_config:
dependency: transitive
description:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
pedantic:
dependency: "direct dev"
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.1"
pool:
dependency: transitive
description:
name: pool
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
pub_semver:
dependency: transitive
description:
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
pubspec_parse:
dependency: transitive
description:
name: pubspec_parse
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
shelf:
dependency: transitive
description:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
source_gen:
dependency: transitive
description:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
stream_transform:
dependency: transitive
description:
name: stream_transform
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
timing:
dependency: transitive
description:
name: timing
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
watcher:
dependency: transitive
description:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
sdks:
dart: ">=2.12.0 <3.0.0"
I see, looks like # Generated by pub
is still set, should say # Generated by melos
- I think that change may only be in the v1.0.0-dev.X releases (or was this another file @rrousselGit?) - could you try v1.0.0-dev.3? Thanks
I see, looks like
# Generated by pub
is still set, should say# Generated by melos
- I think that change may only be in the v1.0.0-dev.X releases (or was this another file @rrousselGit?) - could you try v1.0.0-dev.3? Thanks
Just tried with melos
1.0.0-dev.3
and got the same error. BTW, it still shows # Generated by pub
at the top of my pubspec.lock after running melos bs
.
Looking at @rrousselGit I don't think it affects this issue at all since that PR was for the .dart_tool/package_config.json
file specifically - are you able to confirm what the generator
field in this file says?
Thanks
This doesn't seem to fix the flutter pub run
case, since this calls pub.interactively
, not pub.get
which the fix above targets. A fix for this would seemingly require the same changes in the pub tool.
I have created a PR for pub
to address this issue.
Any ETA on this one? :)
The pub
team wants to solve this in a more general way, than my original PR did. This new PR implements one of the solutions being discussed.
Is there any work-around for this, or do we simply have to wait until https://github.com/dart-lang/pub/pull/3215 is in?
I face the same problems with for example dartdoc
and fast_i18n
when running with melos.
Is there any work-around for this, or do we simply have to wait until dart-lang/pub#3215 is in? I face the same problems with for example
dartdoc
andfast_i18n
when running with melos.
I wish there was something we could do but we're blocked unfortunately 😭 we have the same issues in some of our repos that use build runner
We probably should look into making PRs similar to the one made in Flutter, but for other tools like dart run
I wish there was something we could do but we're blocked unfortunately 😭 we have the same issues in some of our repos that use build runner
Interesting build_runner
actually worked for us, as long as it ran with -c 1
.
The issue is fairly inconsistent. I've had times where the command pass and times where it doesn't. I haven't seen an obvious reason as to why
Not sure if it helps, but I just bumped into this issue and explicitly adding the path
key in my pubspec.yaml (where the dependency on a local package was) made build_runner work in one of my monorepo packages
Seems like re-running melos bootstrap
also solves it temporarily.
With the release of Dart 2.17.0
in the stable channel of the Dart and Flutter SDK, a new mechanism for overriding dependencies has become generally available that Melos can take advantage of to better integrate with other tooling and solve this issue. To activate this feature, add this option to melos.yaml
:
command:
bootstrap:
usePubspecOverrides: true
When this option is enabled, Melos will generate a pubspec_overrides.yaml
file in the root of every package during bootstrapping. This file should not be tracked in version control and should be added to .gitignore
.
It is no longer necessary to set dart.runPubGetOnPubspecChanges
to false
in .vscode/setting.json
because running dart/flutter pub get
after bootstrapping a repository no longer negates the dependency overrides created by Melos.
It is also no longer necessary to run flutter pub get
before melos bootstrap
to ensure that Flutter generated files exist because packages are bootstrapped in place and not in a temporary area.
dart test
works because it doesn't negate the dependency overrides created by Melos.
A caveat is that because of a bug in pub
whose fix is not jet in the stable channel, publishing of packages cannot be performed while pubspec_overrides.yaml
exists. A workaround is to run melos clean
before melos publish
, which removes pubspec_overrides.yaml
s if they were generated by Melos.
With the release of Dart
2.17.0
in the stable channel of the Dart and Flutter SDK, a new mechanism for overriding dependencies has become generally available that Melos can take advantage of to better integrate with other tooling and solve this issue. To activate this feature, add this option tomelos.yaml
:command: bootstrap: usePubspecOverrides: true
When this option is enabled, Melos will generate a
pubspec_overrides.yaml
file in the root of every package during bootstrapping. This file should not be tracked in version control and should be added to.gitignore
.It is no longer necessary to set
dart.runPubGetOnPubspecChanges
tofalse
in.vscode/setting.json
because runningdart/flutter pub get
after bootstrapping a repository no longer negates the dependency overrides created by Melos.It is also no longer necessary to run
flutter pub get
beforemelos bootstrap
to ensure that Flutter generated files exist because packages are bootstrapped in place and not in a temporary area.A caveat is that because of a bug in
pub
whose fix is not jet in the stable channel, publishing of packages cannot be performed whilepubspec_overrides.yaml
exists. A workaround is to runmelos clean
beforemelos publish
, which removespubspec_overrides.yaml
s if they were generated by Melos.
For me, this didn't work at first, because I had a really old melos version (1.5.2
). Make sure to update to the most recent version or a version which supports command
bootstrap
(i assume it's supported by version >= 2.1.0
).
I updated melos
by running dart pub global activate melos
Now build_runner
works properly - great job 👍🏻