Skip to content
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

build_runner fails on Windows with dependencies using git and path #3137

Closed
technolion opened this issue Jun 28, 2021 · 11 comments
Closed

build_runner fails on Windows with dependencies using git and path #3137

technolion opened this issue Jun 28, 2021 · 11 comments

Comments

@technolion
Copy link

technolion commented Jun 28, 2021

When using a dependency like this:

  menubar:
    git:
      url: https://github.com/google/flutter-desktop-embedding.git
      path: plugins/menubar

build_runner fails parsing the path correctly on Windows:

dart run build_runner build
Could not find a file named "pubspec.yaml" in "C:\Users\tom\AppData\Local\Pub\Cache\git\flutter-desktop-embedding-e48abe7c3e9ebfe0b81622167c5201d4e783bb81\plugins%5Cmenubar".

As one can see from the error, it looks like the path parameter of the git dependency leads to an encoded backslash (%5C) which somehow messes up build_runner.

The above way to add a dependency via git is an officially supported syntax:
https://dart.dev/tools/pub/dependencies

  • Dart SDK version: 2.14.0-188.5.beta (beta) (Thu Jun 24 15:29:20 2021 +0200) on "windows_x64"
  • build_runner version 2.0.5
  • Windows 10 operating system
@jakemac53
Copy link
Contributor

Interesting, can you link your .dart_tool/package_config.json file? Or just the entry for that package? I am curious to see if the backslash is encoded in there as well (that should be where we get paths from).

@technolion
Copy link
Author

Sure:

{
  "configVersion": 2,
  "packages": [
    {
      "name": "async",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/async-2.7.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "boolean_selector",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/boolean_selector-2.1.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "characters",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/characters-1.1.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "charcode",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/charcode-1.2.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "clock",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/clock-1.1.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "collection",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/collection-1.15.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "cupertino_icons",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/cupertino_icons-1.0.3",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "fake_async",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/fake_async-1.2.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "flutter",
      "rootUri": "file:///C:/Users/tom/Development/flutter/packages/flutter",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "flutter_lints",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_lints-1.0.3",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "flutter_test",
      "rootUri": "file:///C:/Users/tom/Development/flutter/packages/flutter_test",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "lints",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/lints-1.0.1",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "matcher",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/matcher-0.12.10",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "menubar",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/git/flutter-desktop-embedding-e48abe7c3e9ebfe0b81622167c5201d4e783bb81/plugins/menubar",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "meta",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/meta-1.4.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "path",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/path-1.8.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "sky_engine",
      "rootUri": "file:///C:/Users/tom/Development/flutter/bin/cache/pkg/sky_engine",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "source_span",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/source_span-1.8.1",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "stack_trace",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/stack_trace-1.10.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "stream_channel",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/stream_channel-2.1.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "string_scanner",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/string_scanner-1.1.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "term_glyph",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/term_glyph-1.2.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "test_api",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/test_api-0.4.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "typed_data",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/typed_data-1.3.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "vector_math",
      "rootUri": "file:///C:/Users/tom/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/vector_math-2.1.0",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    },
    {
      "name": "build_runner_test",
      "rootUri": "../",
      "packageUri": "lib/",
      "languageVersion": "2.12"
    }
  ],
  "generated": "2021-06-28T16:52:30.635680Z",
  "generator": "pub",
  "generatorVersion": "2.14.0-188.5.beta"
}

The package is correctly installed in that directory:
Bildschirmfoto 2021-06-30 um 09 32 10

@jakemac53
Copy link
Contributor

Interesting... the package config looks fine.

@technolion
Copy link
Author

Maybe another relevant piece of information is that I discovered this with a flutter project on Flutter's beta channel.

@technolion
Copy link
Author

I just switched to Flutter's stable branch and can confirm, that the error does not appear!
Do you have an idea, what the cause can be?

@jakemac53
Copy link
Contributor

I do not yet, no. I haven't had a chance to dive into this but I will try and take a look in a bit.

@jakemac53
Copy link
Contributor

As far as I can tell though this is where we create the path

.

If you wanted to you could try some local debugging to see how the path looks at that point (check package.root and package.root.toFilePath() to see how they look).

You can see some initial help on how to debug the build script here https://github.com/dart-lang/build/blob/master/docs/builder_author_faq.md#how-can-i-debug-my-builder although the actual debugging part is IDE specific. I can give an example vscode config if you would like.

@technolion
Copy link
Author

Thank you. I will try to debug it tomorrow. The vscode example config would definitely be of help, as I use this IDE.

@jakemac53
Copy link
Contributor

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "build script",
            "program": ".dart_tool/build/entrypoint/build.dart",
            "request": "launch",
            "type": "dart",
            // "cwd": "Set this to your package subdir if not the root",  
            "args": [
                "build",
                "--delete-conflicting-outputs"
            ]
        }
    ]
}

@jakemac53
Copy link
Contributor

It looks like this is now a duplicate of dart-lang/pub#3012 where the underlying issue is being tracked, going to go ahead and close this one.

@enloc-port
Copy link

enloc-port commented Jun 30, 2022

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
None yet
Projects
None yet
Development

No branches or pull requests

3 participants