Skip to content

Add --packages flag to dart run in arcade serve for Dart 3.10 compatibility#61

Merged
exaby73 merged 5 commits intomainfrom
copilot/resolve-package-config-json
Nov 20, 2025
Merged

Add --packages flag to dart run in arcade serve for Dart 3.10 compatibility#61
exaby73 merged 5 commits intomainfrom
copilot/resolve-package-config-json

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

Dart 3.10's resident frontend compiler (-r flag) breaks Isolate.resolvePackageUri, causing it to return null. The workaround is passing --packages=<path> to dart run. In Dart workspaces, package_config.json may be in a parent directory.

Changes

  • packages/arcade_cli/lib/utils.dart: Added findPackageConfig() to recursively search parent directories for .dart_tool/package_config.json

  • packages/arcade_cli/lib/commands/serve.dart:

    • Added _buildDartRunArgs() helper to construct dart command with --packages flag
    • Applied to both initial server start and hot reload restarts
  • packages/arcade_cli/test/utils_test.dart: Test coverage for package config resolution scenarios

Example

Running from a workspace subdirectory now generates:

dart run -r --packages=/workspace/root/.dart_tool/package_config.json bin/app.dart
Original prompt

This section details on the original issue you should resolve

<issue_title>Resolve .dart_tool/package_config.json in arcade serve</issue_title>
<issue_description>In Dart 3.10, when using the resident frontend compiler like we are, Isolate.resolvePackageUri returns null always. See below referenced issue.

A workaround is to pass the package_config.json file as the --packages option to dart run. So the final command would be:

$ dart run -r --packages=./.dart_tool/package_config.json bin/project.dart

To solve this, we'd need to resolve the .dart_tool/packages.json. Usually, it would be in the current working directory. But since Dart has monorepo support via Dart workspaces, we should recursively search parent directories for this file

See dart-lang/sdk#62009</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: exaby73 <50555895+exaby73@users.noreply.github.com>
@exaby73 exaby73 marked this pull request as ready for review November 20, 2025 15:11
Co-authored-by: exaby73 <50555895+exaby73@users.noreply.github.com>
Copy link
Collaborator

@exaby73 exaby73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Good work. Just one small change

Comment on lines 67 to 72
// Build the dart run arguments, including --packages if found
final runArgs = ['run', '-r'];
if (packageConfig != null) {
runArgs.addAll(['--packages=$packageConfig']);
}
runArgs.add(serverFile.path);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you extract this into a private method to dedupe code here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Extracted into _buildDartRunArgs() private method in commit 0b07cbb.

…cation

Co-authored-by: exaby73 <50555895+exaby73@users.noreply.github.com>
@exaby73 exaby73 changed the title [WIP] Fix resolution of package_config.json in arcade serve fix: Resolution of package_config.json in arcade serve Nov 20, 2025
Co-authored-by: exaby73 <50555895+exaby73@users.noreply.github.com>
Copilot AI changed the title fix: Resolution of package_config.json in arcade serve Add --packages flag to dart run in arcade serve for Dart 3.10 compatibility Nov 20, 2025
Copilot AI requested a review from exaby73 November 20, 2025 15:20
@exaby73 exaby73 merged commit 2695b79 into main Nov 20, 2025
17 checks passed
@exaby73 exaby73 deleted the copilot/resolve-package-config-json branch November 20, 2025 15:35
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

Successfully merging this pull request may close these issues.

Resolve .dart_tool/package_config.json in arcade serve

2 participants