melos
melos copied to clipboard
fix: Melos scripts `exec` only works if globally installed
Is there an existing issue for this?
- [X] I have searched the existing issues.
Version
3.0.1
Description
Melos throws an error if not globally installed when running scripts that use exec.
This might be due to melos not running with the path it is currently executed from but rather assumes its globally installed.
Why is this a problem?
We currently face the issue that we can't run melos script that use exec in our CI/CD without installing it globally.
Potential solution:
Maybe the usage of Platform.script can be helpful to use the correct melos path.
// https://github.com/invertase/melos/blob/main/packages/melos/lib/src/scripts.dart#L280
final parts = [Platform.executable, Platform.script.path, 'exec'];
(not tested)
Steps to reproduce
melos.yaml
name: test
packages:
- packages/*
scripts:
test:
name: test
exec: echo Hi
pubspec.yaml
name: test_workspace
environment:
sdk: '>=2.18.0 <3.0.0'
dev_dependencies:
melos: ^3.0.1
Running the following will cause an error:
> flutter pub run melos run test
melos run test
â””> melos exec -- "echo Hi"
â””> RUNNING
/bin/sh: melos: command not found
melos run test
â””> melos exec -- "echo Hi"
â””> FAILED
ScriptException: The script test failed to execute.
pub finished with exit code 1
Expected behavior
No failure when running the script since all other features work without the need of having melos installed globally.
Screenshots
No response
Additional context and comments
No response
Same problem
@Tandashi @zhyky do you still face this problem?
@spydon
Yes the problem still exists even with melos 3.4.0 installed.
> dart run melos run test
/bin/sh: melos: command not found