Skip to content

dart run <package>@ does not provide a package config URI #63186

Open

Description

@jakemac53

I was trying the latest <package>@ support and noticed that pubviz does not work with it due to requiring a package config to look up its own assets, using the Isolate.resolvePackageUri API.

I don't know if this is running AOT compiled or not, but either way we should be able to provide a package config, as one definitely is present.

Reproduction steps

dart run pubviz@

Results in:

Bad state: Could not resolve package:pubviz/assets/
package:pubviz/src/executable.dart 64                            _createOrOpen
===== asynchronous gap ===========================
dart:async                                                       _CustomZone.registerBinaryCallback
../../.pub-cache/hosted/pub.dev/pubviz-6.0.0/bin/pubviz.dart 55  _main.<fn>
package:stack_trace                                              Chain.capture
../../.pub-cache/hosted/pub.dev/pubviz-6.0.0/bin/pubviz.dart 53  _main
../../.pub-cache/hosted/pub.dev/pubviz-6.0.0/bin/pubviz.dart 17  main.<fn>
dart:async                                                       runZoned
package:io/src/ansi_code.dart 34                                 overrideAnsiOutput
../../.pub-cache/hosted/pub.dev/pubviz-6.0.0/bin/pubviz.dart 

Which is failing here.

Activity

  1. added
    area-dart-cliUse area-dart-cli for issues related to the 'dart' command like tool.
    on Apr 16, 2026
  2. jakemac53 commented on Apr 16, 2026

    @jakemac53
    ContributorAuthor

    cc @sigurdm @jonasfj @bkonyi I am not sure who is actually driving this work

    cc @kevmoo as the pubviz owner

  3. bkonyi commented on Apr 16, 2026

    @bkonyi
    Contributor

    I'm fairly certain this is running in an executable, so it doesn't have access to its own package_config.json.

  4. jakemac53 commented on Apr 16, 2026

    @jakemac53
    ContributorAuthor

    I'm fairly certain this is running in an executable, so it doesn't have access to its own package_config.json.

    I believe though that you can pass in a --packages <path> when launching it? If not we should see if we can support that so that these APIs can work.

  5. jakemac53 commented on Apr 16, 2026

    @jakemac53
    ContributorAuthor

    Alternatively packages should be able to configure in what mode they will run - for instance if they are not AOT compatible they should be able to opt out of that mode and run via precompiled kernel instead (or some other mode). This would also enable dart install to be more broadly applicable.

  6. jakemac53 commented on Apr 16, 2026

    @jakemac53
    ContributorAuthor

    cc @dcharkes as well

  7. dcharkes commented on Apr 16, 2026

    @dcharkes
    Contributor

    Alternatively packages should be able to configure in what mode they will run - for instance if they are not AOT compatible they should be able to opt out of that mode and run via precompiled kernel instead (or some other mode). This would also enable dart install to be more broadly applicable.

    The goal of dart install is to use self-contained bundles. If you want to run from a kernel snapshot, it would require copying dart.exe and all the snapshots it need into the app bundle to make it self-contained.

    to look up its own assets

    Since Dart does not have a concept of data assets (unlike Flutter), there is no way to make assets available in a self-contained bundle. If we start supporting data assets to be reported from hook/build.dart and introduce a Dart API (analogous to the Flutter asset bundles), we can support this. The work is tracked in:

    The workaround is: Base64 encode your asset as a Dart String.

    An alternative is to add pubviz to the dev dependency of projects and run it with dart run pubviz instead. @sigurdm has been advocating to use this more often as it will ensure versioning your dev utilities.

  8. kevmoo commented on Apr 16, 2026

    @kevmoo
    Member
  9. jakemac53 commented on Apr 17, 2026

    @jakemac53
    ContributorAuthor

    The goal of dart install is to use self-contained bundles. If you want to run from a kernel snapshot, it would require copying dart.exe and all the snapshots it need into the app bundle to make it self-contained.

    Why is this the goal? What user journey is this solving for?

    Without some sort of asset bundling solution in place this ignores many of the use cases that currently work, and just leads to confusion. We cannot deprecate dart pub global activate, as some tools only work that way, and we now have APIs which will throw runtime errors only when installed via dart install or ran via dart run <package>@.

    This is bad for users because it is extremely confusing, it just adds more options instead of unifying things, etc.

  10. jakemac53 commented on Apr 17, 2026

    @jakemac53
    ContributorAuthor

    Setting aside dart install, I would argue that AOT is not at all the correct compiler to use for dart run <package>@, for the following reasons:

    • These should be considered more of an "ephemeral" execution, and should prioritize time to start executing main over runtime performance. For a large number of these tools the compilation will take longer than the tool execution.
    • No incremental compilation when packages update.
    • Causes runtime errors for core APIs with no static warnings of any type.

    The best compilation mode for this use case is the incremental kernel compiler, because:

    • It is the fastest path to executing main for the first run or recompiles, and is fast enough for cached runs that nobody will notice it is slower than AOT.
    • Supports incremental compilation when packages update
    • All core APIs work without unexpected runtime errors

    Ideally, package authors would be able to choose the default compilation strategy though, since there are trade-offs and no approach will be best for all packages.

  11. dcharkes commented on Apr 20, 2026

    @dcharkes
    Contributor

    when packages update

    I'd argue there are two types of command-line tools that you can use. (1) The package version matters, (2) the package version doesn't matter.

    For (1), it's tightly connected to your project. I'd say these should be dev_dependencies and be dart run without @. You'd control the version tightly with non-caret pubspec.yaml or by checking in the pubspec lock.

    For (2), these tools should not matter what version they are. E.g. clang, git, .. They are standalone executables. You don't care about what internal versions of the dependencies are used. They have a stable public CLI. These are the ones that are dart installed.

    Ideally, package authors would be able to choose the default compilation strategy though, since there are trade-offs and no approach will be best for all packages.

    What you're saying is you want the package author to be able to say which of these two types a package is so that dart run @ would automatically pick the right of these two modes?

    All core APIs work without unexpected runtime errors

    Can you elaborate on this? Which core APIs are you referring to? Where are these APIs defined? CLIs? json formats? Are these APIs stable?

  12. jakemac53 commented on Apr 29, 2026

    @jakemac53
    ContributorAuthor

    What you're saying is you want the package author to be able to say which of these two types a package is so that dart run @ would automatically pick the right of these two modes?

    Correct, I think the package author should be able to determine how their package is compiled and installed. They are ultimately in the best position to make that decision.

    This could also be handled by just specifying a set of requirements (dart:mirrors, dart:isolate). But this gets tricky when its actually individual APIs within those libraries which are required.

    All core APIs work without unexpected runtime errors

    Can you elaborate on this? Which core APIs are you referring to? Where are these APIs defined? CLIs? json formats? Are these APIs stable?

    Specifically in this case it's Isolate.resolvePackageUri, but also things like dart:mirrors work. There might also be others although I am not sure. Mirrors is of course experimental still, but Isolate.resolvePackageUri is stable. But afaik the VM is the only environment that supports every API (except the web ones).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-dart-cliUse area-dart-cli for issues related to the 'dart' command like tool.dart-cli-runIssues related to 'dart run'

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions