melos
melos copied to clipboard
fix: Error while generating Intellij Files after melos boostrap
Is there an existing issue for this?
- [X] I have searched the existing issues.
Version
2.3.1
Description
Melos throw this error while bootstrap project using melos bs
melos cli is /Users/evaisse/.pub-cache/bin/melos
But it looks like the path extract by utils.getMelosRoot() gives /root/.pub-cache/hosted/pub.dartlang.org/melos-2.3.1
Generating IntelliJ IDE files...
Unhandled exception:
FileSystemException: Cannot open file, path = '/root/.pub-cache/hosted/pub.dartlang.org/melos-2.3.1/templates/intellij/modules/flutter_app_module.iml.tmpl' (OS Error: No such file or directory, errno = 2)
#0 _File.open.<anonymous closure> (dart:io/file_impl.dart:356:9)
<asynchronous suspension>
#1 IntellijProject.readFileTemplate (package:melos/src/common/intellij_project.dart:136:22)
<asynchronous suspension>
#2 IntellijProject.writePackageModule (package:melos/src/common/intellij_project.dart:169:22)
<asynchronous suspension>
#3 IntellijProject.generate.<anonymous closure> (package:melos/src/common/intellij_project.dart:317:7)
<asynchronous suspension>
#4 _RootZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1657:12)
<asynchronous suspension>
below flutter doctor output :
[✓] Flutter (Channel stable, 3.0.0, on macOS 12.4 21F79 darwin-x64, locale fr-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.64.0)
Steps to reproduce
- at root level in your project (like melos.yaml)
- run
melos bs
Expected behavior
The bug is non blocking, it occurs after flutter pub get and all critical tasks.
Screenshots
No response
Additional context and comments
No response
This looks like you have multiple Dart SDKs with different .pub-cache locations, where one cache contains the right version of melos, but somehow another is resolved at runtime.
Could you run which -a dart to check which Dart SDKs are on the path?
Are we also correctly handling the PUB_CACHE env variable in our check to file the melos lib path?
We are using Isolate.resolvePackageUri. Not sure how that works internally, though.
https://github.com/invertase/melos/blob/main/packages/melos/lib/src/common/utils.dart#L194-L199
which -a dart resolution is : /usr/local/opt/flutter/bin/dart and no PUB_CACHE in my env.
The default location for .pub_cache is $HOME. So, if melos looks for files in /root/.pub-cache, that hints to an issue related to sudo or some other way that melos is executing as root, which you probably don't want to do.
Maybe reinstalling melos helps 🤷
hello sir, how to reinstall melos?
Please try the following commands:
dart pub global deactivate melos
# Also clean the pub cache in case it is corrupted.
dart pub cache clean
dart pub global activate melos
Please try the following commands:
dart pub global deactivate melos # Also clean the pub cache in case it is corrupted. dart pub cache clean dart pub global activate melos
Sorry, I want to ask something, I hope you like it. in my project using melos, i have done some melos command in my project. one time I found an error like in the picture. The weird thing is that the darts plugin is the latest and my android studio is also the latest version. the error only appears in the project and if I open the project in visual studio the error does not appear. Sorry, I'm asking like this because at first I was interested in the comments about reinstalling Melos. I'm afraid my problem occurs because of melos, because I've gotten this error twice.

@evaisse is this still happening? Did you perhaps run it with sudo like blaugold suggested?