Skip to content

fix: dart_frog build in a pub workspace (dart ^3.5) #1518

New issue

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

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

Already on GitHub? # to your account

Open
Leptopoda opened this issue Sep 16, 2024 · 5 comments
Open

fix: dart_frog build in a pub workspace (dart ^3.5) #1518

Leptopoda opened this issue Sep 16, 2024 · 5 comments
Labels
bug Something isn't working as expected p2 Important issues not at the top of the work list

Comments

@Leptopoda
Copy link
Contributor

Description

dart_frog build fails when run in a pub workspace package.
The issue seems to be that a pub workspace will only generate one global pbspec.lock file for the entire repository. Therefore, the post gen hook of the dart_frog_prod_server mason module fails.

 dart_frog build 
✓ Installing dependencies (3.4s)
✓ Bundling sources (0.2s)
An exception occurred while executing hook:REDACTED/.mason-cache/bundled/dart_frog_prod_server_0.1.0+1_8f9e5f00a1ad5ac6fe64824ffeb33163fed9b0ba/hooks/pre_gen.dart.
Error: PathNotFoundException: Cannot open file, path = 'REDACTED/packages/api/pubspec.lock' (OS Error: No such file or directory, errno = 2)

Steps To Reproduce

  1. create a dart pub workspace mono repo
  2. cd packages/api (the package our server code is living in)
  3. dart_frog build

Expected Behavior

dart_frog manages to build the server code.

Additional Context

For reference, pub workspaces are the new dart native mono repo management, which is currently in preview since dart 3.5.
More info at: https://flutter.dev/go/pub-workspace

@Leptopoda Leptopoda added the bug Something isn't working as expected label Sep 16, 2024
@tomarra
Copy link
Contributor

tomarra commented Sep 24, 2024

Hi @Leptopoda 👋 Thanks for opening this issue!

In talking with the team we do believe that this is a valid bug as we have not added in support for Workspaces at this time to any of our packages. The main reason for this is that overall the Workspaces feature is still experimental from the Dart team. This was pointed out by the team in the post announcing the 3.5 release

We believe the fundamental solution is to create a single, shared resolution of the versions of each dependency in such repos, and are working on such a capability via a new pub feature called workspaces. We’ll have much more to share about this in our next Dart release, but for now you can go ahead and see how this was recently applied to the Flutter engine repo.

Given this, I'm going to leave the issue open as it is valid but we won't plan on re-evaluating it until the Workspace feature is complete and fully launched by the Dart team.

@tomarra tomarra added the p3 Issues that we currently consider unimportant label Sep 24, 2024
@tomarra tomarra moved this from Needs Triage to Backlog in VGV Open Source 🦄 🧙🌟 Sep 24, 2024
@Leptopoda
Copy link
Contributor Author

It might be time to re evaluate as workspaces hit GA a few days ago with dart 3.6

@tomarra tomarra moved this from Backlog to Needs Triage in VGV Open Source 🦄 🧙🌟 Dec 17, 2024
@tomarra
Copy link
Contributor

tomarra commented Dec 17, 2024

Notes from Grooming Session with team

  • There's an overall dependency here with Docker that kind of gets in the way of some of this.
  • Wondering if there is a way to enable this support for development and keep the building for production a separate path. This may need the plugin system to be developed first. This could also make custom docker builds easier for people to maintain.
  • Need to create a test/sample project with our prescribed repo layout/setup to fully test this out and figure out next steps.

@tomarra tomarra added p2 Important issues not at the top of the work list and removed p3 Issues that we currently consider unimportant labels Dec 17, 2024
@tomarra tomarra moved this from Needs Triage to Todo in VGV Open Source 🦄 🧙🌟 Dec 17, 2024
@Schamppu
Copy link

Not having workspace support has now become a major roadblock for us. We've been using dart_frog for a long time now in our MMORPG, and we've converted all of our packages that are shared between different projects to use workspace resolution. dart_frog not supporting this now means we need to have separate branches where that is disabled for our packages, which is a major hassle to deal with and creates a lot of unnecessary overhead.

And not having the better dependency management, easier local development, unified tooling and improved analyzer performance are making us doubt if we should keep using dart_frog as our server infrastructure unless this is enabled. At least clear communication when workspace support will be released for dart_frog would be something that would make us feel better to keep using dart_frog.

@marcossevilla
Copy link

I'm currently working on a PR to support workspaces on my dart_frog fork. I have progress on it regarding getting dependencies from pubspec.lock but also found we need to define whether to copy package dependencies from the monorepo as path dependencies to the build folder or another approach to achieve it since the behavior and monorepo structure can change depending on the project.

This is my working PR.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working as expected p2 Important issues not at the top of the work list
Projects
Status: Todo
Development

No branches or pull requests

4 participants