melos icon indicating copy to clipboard operation
melos copied to clipboard

fix: Error while generating Intellij Files after melos boostrap

Open evaisse opened this issue 3 years ago • 9 comments

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

  1. at root level in your project (like melos.yaml)
  2. 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

evaisse avatar Jun 16 '22 12:06 evaisse

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?

blaugold avatar Jun 17 '22 14:06 blaugold

Are we also correctly handling the PUB_CACHE env variable in our check to file the melos lib path?

Salakar avatar Jun 17 '22 14:06 Salakar

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

blaugold avatar Jun 17 '22 14:06 blaugold

which -a dart resolution is : /usr/local/opt/flutter/bin/dart and no PUB_CACHE in my env.

evaisse avatar Jun 17 '22 17:06 evaisse

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 🤷

blaugold avatar Jun 17 '22 17:06 blaugold

hello sir, how to reinstall melos?

abdulrojakdev avatar Aug 15 '22 09:08 abdulrojakdev

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

blaugold avatar Aug 15 '22 11:08 blaugold

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.

0410BDCD-DFE8-4A35-B5FB-54DB58FDFC7D_1_105_c

abdulrojakdev avatar Aug 15 '22 15:08 abdulrojakdev

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

spydon avatar Dec 04 '23 18:12 spydon