Skip to content

pubspec.lock paths are incompatible on Windows #3012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
creativecreatorormaybenot opened this issue May 24, 2021 · 12 comments · Fixed by #3063
Closed

pubspec.lock paths are incompatible on Windows #3012

creativecreatorormaybenot opened this issue May 24, 2021 · 12 comments · Fixed by #3063
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@creativecreatorormaybenot
Copy link
Contributor

Environment

Pub 2.14.0-edge.a527411e5100a0a4f48c4009087a1b988aa784af
Dart SDK version: 2.14.0-edge.a527411e5100a0a4f48c4009087a1b988aa784af (be) (Fri May 14 15:47:38 2021) on "windows_x64"

Problem

When using dart pub run build_runner build (using the build_runner package), the command immediately crashed because:

Could not find a file named "pubspec.yaml" in "Pub\Cache\git\foo-<git-hash>\packages%5Cbar".

The pubspec.yaml for this package looks like this:

dev_dependencies:
  foo:
    git:
      url: [email protected]:user/repo.git
      path: packages/bar
      ref: some-tag

The generated pubspec.lock for this package looks like this:

  foo:
    dependency: "direct dev"
    description:
      path: "packages\\bar"
      ref: "some-tag"
      resolved-ref: <git-tag>
      url: "[email protected]:user/repo.git"
    source: git
    version: "0.1.1"

And here it was immediately obvious to me: packages\\bar was the culprit.

Expected behavior

  1. The path in the pubspec.lock should be a forward slash (packages/bar) as the lock file should be version controlled for apps, which means that non-Windows users should use the same lock file.
  2. The end result should be that flutter pub run build_runner build works :)

Actual behavior

Could not find a file named "pubspec.yaml" in "Pub\Cache\git\foo-<git-hash>\packages%5Cbar".

Workaround

I figured out a workaround solution:

  1. Manually change the path from packages\\bar to packages/bar in the pubspec.lock file.
  2. Success (flutter pub run build_runner build runs successfully).
@jonasfj jonasfj added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label May 25, 2021
@jonasfj
Copy link
Member

jonasfj commented May 25, 2021

Hmm, it seems reasonable that pubspec.lock is consistent across platforms.

@technolion
Copy link

Please also see dart-lang/build#3137

@ZeroOneTV
Copy link

ZeroOneTV commented Jul 21, 2021

@creativecreatorormaybenot
I understand how you explained it and it really applies to my case. However, when I run the command: pub run build_runner build , it says that the file has changed and that I should run pub get again.
How do I get around this problem?

@creativecreatorormaybenot
Copy link
Contributor Author

@ZeroOneTV For me, it is enough to run pub get get again and then only change these lines (or 2 characters).
This does not seem to change the integrity of the file.

But I do also agree that this is a big issue and should be prioritized in some way because it basically breaks the functionality.

@ZeroOneTV
Copy link

@ZeroOneTV For me, it is enough to run pub get get again and then only change these lines (or 2 characters).
This does not seem to change the integrity of the file.

But I do also agree that this is a big issue and should be prioritized in some way because it basically breaks the functionality.

This is before modification:
image

After change line:
image

@creativecreatorormaybenot
Copy link
Contributor Author

@ZeroOneTV I have seen the error, but it does not consistently appear for me as I said.

I suggest you can create an issue on build_runner, so they can prioritize this 👍

@ZeroOneTV
Copy link

@ZeroOneTV I have seen the error, but it does not consistently appear for me as I said.

I suggest you can create an issue on build_runner, so they can prioritize this 👍

Thank you friend, I will create an issue related to this at the latest until tomorrow 👍

@natebosch
Copy link
Member

natebosch commented Jul 30, 2021

cc @sigurdm - do you understand from the description above where the bug is here? Is this something we need to prioritize before the next stable SDK release?

@sigurdm
Copy link
Contributor

sigurdm commented Aug 2, 2021

Yeah - it is a regression introduced by 86bf8b2 . I will try to work on a fix.

@ZeroOneTV
Copy link

ZeroOneTV commented Aug 2, 2021

As @natebosch mentioned in the issue I opened, here would be the best place to present my error
In my case, the situation is this:

Problem information

  • Windows 10 Pro • Version 20H2 (Compilation 19042.1110)
  • Flutter 2.5.0-1.0.pre • channel dev • https://github.com/flutter/flutter.git
  • Framework • revision 184e5871be (4 days ago) • 2021-07-26 04:38:02 -0400
  • Engine • revision a877f6fed6
  • Tools • Dart SDK version: 2.14.0-350.0.dev (dev) (Fri Jul 23 20:45:53 2021 -0700) on "windows_x64"
  • build_runner version: "2.0.6"
  • json_serializable: ^4.1.0 || mockito: ^5.0.11 || moor_generator: ^4.4.1 || using theses builds

Making use of these packages mentioned, i'm currently trying to run build_runner to generate the .g models and mocks for testing.
But, when I run flutter pub run build_runner build --delete-conflicting-outputs or dart run build_runner build --delete-conflicting-outputs

I get the following error:

Could not find a file named "pubspec.yaml" in "C:\Users\Zero\AppData\Local\Pub\Cache\git\flutter_plugins-fe50c5bb70cde2cbec931f082aabad229e8003d7\packages%5Cequalizer".
pub finished with exit code 66 
Could not find a file named "pubspec.yaml" in "C:\Users\Zero\AppData\Local\Pub\Cache\git\flutter_plugins-fe50c5bb70cde2cbec931f082aabad229e8003d7\packages%5Cequalizer".

I tried to remove the backslash from pubspec.lock file but I get the error:

The pubspec.lock file has changed since the .packages file was generated, please run "pub get" again.
pub finished with exit code 65

This error occurs on flutter channel:

  • Dev
  • Beta
  • Master

The only one in which the build is possible without major problems is the Stable channel.

@Sese-Schneider
Copy link

FYI for anyone finding this issue:

Fixed (CP) in the newest version of the stable Dart SDK.
dart-lang/sdk#47186 (comment)

@enloc-port
Copy link

In my case, the reason for this problem was that I used to pull the packges using flutter pub get, but I ran build_runner with dart run build_runner .... But flutter and dart use different working directories.

So be sure to run build_runner with the same command as the one you pulled the packages with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants