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

fix: Melos doesn't work without 'global activation' if 'exec' is used #690

Open
1 task done
wujek-srujek opened this issue Apr 2, 2024 · 1 comment
Open
1 task done
Labels
bug Something isn't working

Comments

@wujek-srujek
Copy link

wujek-srujek commented Apr 2, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

Version

5.3.0

Description

I have the following melos.yaml:

name: test

packages:
  - .
  - packages/*
  - packages/*/example

scripts:
  pwd:
    run: pwd
    exec:
      concurrency: 1
      orderDependents: true

On CI, we turn on melos using dart pub global activate melos. This has issues because if there are more than 1 job running on the system, and melos / dart / flutter versions differ, the second global activation also changes the command for the already running job, and melos commands may fail - this has just happened to me as a job for the main branch failed because another job for an 'upgrade everything' branch globally activated melos in another version (also dart and flutter were different).

So the idea is to not activate it globally on CI, and it makes problems. While calling

dart run melos --version

works, this doesn't:

$ dart run melos run --no-select pwd
melos run pwd> melos exec --concurrency 1 --order-dependents -- "pwd"> RUNNING

ERROR: /bin/sh: melos: command not found


melos run pwd> melos exec --concurrency 1 --order-dependents -- "pwd"> FAILED
ScriptException: The script pwd failed to execute.

This is likely because Melos is trying to shell out, and the new processes don't find the melos command.

Yes, melos is not on PATH, but that's the whole point, I want each job to have it own melos. How do I do that?

It seems to have something to do with using the exec block. If I remove it, it works, but only for the top-level package, which is not what I want:

$ dart run melos run --no-select pwd
melos run pwd> pwd> RUNNING

/Users/wujek/Development/melos_test

melos run pwd> pwd> SUCCESS

Steps to reproduce

  1. Deactivate melos globally (if activated): dart pub global deactivate melos.
  2. Try to call a script with dart run melos run ....

Expected behavior

The command works.

@wujek-srujek wujek-srujek added the bug Something isn't working label Apr 2, 2024
@wujek-srujek wujek-srujek changed the title fix: Allow running melos without 'global activation' fix: Melos doesn't work without 'global activation' if 'exec' is used Apr 2, 2024
@wujek-srujek
Copy link
Author

wujek-srujek commented Apr 10, 2024

To make it work on CI we now set PUB_CACHE so that each GitHub Actions runner gets its own Pub cache and the global activation is scoped to jobs on that runner only, effectively fixing the issue for us.

There are other ways to make it work as well, like setting a different $HOME for each runner, which effectively also scopes dart/flutter/melos to that directory.

However, the underlying issue in Melos that it cannot be used without global activation persist. Others might not be able to use my approach so fixing this issue would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant