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

Support server restarts using pub workspaces #3721

Open
sigurdm opened this issue Jun 21, 2024 · 6 comments
Open

Support server restarts using pub workspaces #3721

sigurdm opened this issue Jun 21, 2024 · 6 comments

Comments

@sigurdm
Copy link
Contributor

sigurdm commented Jun 21, 2024

Currently one has to manually restart build_runner on each pub get when using workspaces.

Context being discussed in #3717

@natebosch
Copy link
Member

I think this is the main problem

var packageConfigId = AssetId(_targetGraph.rootPackageConfig.packageName,
'.dart_tool/package_config.json');

This is already broken for some non-standard setups if the file isn't at exactly the hardcoded path. We could fix this for unexpected paths under the root package, but as Jake mentioned this causes a problem when the package config is outside of any package.

My first hacky idea is to add a synthetic package for this, I think we discover the package config when building the package graph so we should have the information we need. We'll also need to communicate that path through to the above lines, so we probably need to add it as another field on both PackageGraph and TargetGraph.

@jakemac53
Copy link
Contributor

True, we could go the synthetic package route similar to how we handle SDK sources. Not sure what we want to call it, $workspace?

@natebosch
Copy link
Member

Hmm, build_runner doesn't work at all for packages using pub workspaces.

Map<String, DependencyType> _parseDependencyTypes(String rootPackagePath) {
final pubspecLock = File(p.join(rootPackagePath, 'pubspec.lock'));
if (!pubspecLock.existsSync()) {
throw StateError(
'Unable to generate package graph, no `pubspec.lock` found. '
'This program must be ran from the root directory of your package.');
}

I'm not sure how we wouldn't have hit this earlier though...

@natebosch natebosch changed the title Find a way to support monitoring package_config when using workspaces Support packages using pub workspaces Oct 9, 2024
natebosch added a commit to dart-lang/source_gen that referenced this issue Oct 9, 2024
Use non-workspace resolution because `build_runner` does not support
packages where the `pubspec.lock` file is not at the package root.

See dart-lang/build#3721
@natebosch natebosch changed the title Support packages using pub workspaces Support server restarts using pub workspaces Oct 9, 2024
@natebosch
Copy link
Member

Hmm, build_runner doesn't work at all for packages using pub workspaces.

This was a local issue, I still had some .packages files tripping things up.

@sigurdm
Copy link
Contributor Author

sigurdm commented Oct 22, 2024

I think this is done.

@sigurdm sigurdm closed this as completed Oct 22, 2024
@sigurdm sigurdm reopened this Oct 22, 2024
@sigurdm
Copy link
Contributor Author

sigurdm commented Oct 22, 2024

Sorry - I misread what this issue was about. We probably still should do this.

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