Open Ppito opened 9 months ago
Ok I get it... I had forced myself not to set Flutter in my windows environment variables, to make sure I always used the FVM version. Except that since melos 3.2.0 I'm obliged to have this variable set.
This means that a subsystem ignores the sdkPath parameter and expects to use the system configuration.
Thanks for a well written issue, so it works for Melos 3.1.1?
Thanks for a well written issue, so it works for Melos 3.1.1?
yes, it works fine in 3.1.1
That is so strange, because the only changes that are not docs between 3.1.1 and 3.2.0 are:
And #538 only adds some exports, and #590 only adds trailing commas. So there must be something in #526, and I really don't see how that could affect it...
yes, I had inspected the PR too and found nothing. I'll try to make a video presentation.
I just tried to replicate your setup and it works fine for me (so I probably failed to replicate it)...
Used a local fvm and pointed at it with sdkPath
.
My previous isntallation was :
dart pub global activate fvm
Case 1:
sdkPath: .fvm/flutter_sdk
Case 2:
sdkPath: .fvm/flutter_sdk
Case 3:
sdkPath: .fvm/flutter_sdk
I haven't had time to do another test since it's working again for me. I'll try these scenarios again to confirm.
Ah right, I forgot to unset the environment Flutter.
I guess that melos itself needs a flutter version to set itself to the version specified in the root pubspec and I guess it hasn't read the melos.yaml
file yet at that point. I still don't understand which PR that could have affected this though.
You don't have any common dependencies specified in melos.yaml
right?
I don't really know, I'm fairly new to the flutter world and I've just started on a fairly complex project. I wouldn't know what to look for. What do you mean by "common dependencies specified in melos.yaml" ?
I have my main project and 5 internal packages on it.
@Ppito it's a quite new feature so you're probably not using it, but can you post your full melos.yaml
file?
Okay, I'll warn you right now, the configuration isn't mine. š¤£
name: my_app
packages:
- .
- packages/**
sdkPath: .fvm/flutter_sdk
command:
clean:
hooks:
post: melos exec --flutter -- "flutter clean"
bootstrap:
runPubGetInParallel: false
usePubspecOverrides: true
scripts:
# [Format] -----------------------------------------------------------------------------------------------------------
format:
run: melos run format:dart --no-select && melos run format:flutter --no-select
description: Run Dart/Flutter formats in all packages.
format:dart:
run: melos exec --concurrency=1 -- "dart format --output=none --set-exit-if-changed ."
description: Run Dart format in all dart packages.
packageFilters:
flutter: false
ignore: "*example*"
format:flutter:
run: melos exec --concurrency=1 -- "dart format --output=none --set-exit-if-changed ."
description: Run Flutter format in all flutter packages.
packageFilters:
flutter: true
ignore: "*example*"
# [Analyze] ----------------------------------------------------------------------------------------------------------
analyze:
run: melos run analyze:dart --no-select && melos run analyze:flutter --no-select
description: Run Dart/Flutter analyzes in all packages.
analyze:dart:
run: melos exec --concurrency=1 -- "dart analyze ."
description: Run Dart analyze in all dart packages.
packageFilters:
flutter: false
ignore: "*example*"
analyze:flutter:
run: melos exec --concurrency=1 -- "flutter analyze ."
description: Run Flutter analyze in all flutter packages.
packageFilters:
flutter: true
ignore: "*example*"
# [Generate] ---------------------------------------------------------------------------------------------------------
generate:
run: melos run generate:dart --no-select && melos run generate:flutter --no-select
description: Run Dart/Flutter build_runner in all packages.
generate:dart:
run: melos exec --concurrency=1 -- "dart pub run build_runner build --delete-conflicting-outputs"
description: Run Dart build_runner in all dart packages.
packageFilters:
flutter: false
ignore: "*example*"
dependsOn: build_runner
generate:flutter:
run: melos exec --concurrency=1 -- "flutter pub run build_runner build --delete-conflicting-outputs"
description: Run Flutter build_runner in all flutter packages.
packageFilters:
flutter: true
ignore: "*example*"
dependsOn: build_runner
# [Test] -------------------------------------------------------------------------------------------------------------
test:
run: melos run test:dart --no-select && melos run test:flutter --no-select
description: Run Dart/Flutter tests in all packages.
test:dart:
run: melos exec --concurrency=1 --fail-fast -- "dart test"
description: Run Dart test in all dart packages.
packageFilters:
flutter: false
dirExists: test
ignore: "*example*"
test:flutter:
run: melos exec --concurrency=1 --fail-fast -- "flutter test --coverage --test-randomize-ordering-seed random"
description: Run Flutter test in all flutter packages.
packageFilters:
flutter: true
dirExists: test
ignore: "*example*"
test:flutterWithHtmlCoverage:
run: melos exec --concurrency=1 --fail-fast "flutter test --coverage --test-randomize-ordering-seed random --reporter expanded && genhtml coverage/lcov.info --output-directory coverage/html && open coverage/html/index.html"
description: Run Flutter test in all flutter packages with HTML coverage.
packageFilters:
flutter: true
dirExists: test
ignore: "*example*"
# [Flavor] -----------------------------------------------------------------------------------------------------------
dev:
run: melos run qa:dev --no-select
description: Run Dev environment.
mock:
run: melos run qa:mock --no-select
description: Run Mock environment.
staging:
run: melos run qa:staging --no-select
description: Run Staging environment.
production:
run: melos exec -- "flutter run --flavor production"
description: Run with Production flavor in Production environment.
packageFilters:
scope: "my_app"
qa:dev:
run: melos exec -- "flutter run --flavor qa -a ENV=dev"
description: Run with QA flavor in Dev environment.
packageFilters:
scope: "my_app"
qa:mock:
run: melos exec -- "flutter run --flavor qa -a ENV=mock"
description: Run with QA flavor in Mock environment.
packageFilters:
scope: "my_app"
qa:staging:
run: melos exec -- "flutter run --flavor qa -a ENV=test"
description: Run with QA flavor in Staging environment.
packageFilters:
scope: "my_app"
# [UI] ---------------------------------------------------------------------------------------------------------------
widgetbook:
run: melos exec -- "flutter run --device-id chrome -a ENV=dev"
description: Run widgetbook on web.
packageFilters:
scope: "pkg_widgetbook"
Alright, no common dependencies.
And everything looks in order, except that it seems like you are having one package in the root, which is not recommended since the workspace pubspec lives in the root and then will collide with the one for the package/app that you have there, so if I were you I would move that into either packages
or create a directory called apps
where you put it instead. (But this won't change anything with the problem that you were having with the sdkPath
)
It's not really a package on the root, it's my main application ... ^^"
It's not really a package on the root, it's my main application ... ^^"
Then it should be in a directory named the same as your app inside of apps/
:)
So, instead of this :
āāā analysis_options.yaml
āāā android/
āāā assets/
āāā build.yaml
āāā codemagic.yaml
āāā ios/
āāā l10n.yaml
āāā lib/
ā āāā main.dart
āāā LICENSE.md
āāā melos.yaml
āāā packages/
ā āāā pkg_name1/
ā āāā pkg_name2/
ā āāā pkg_name3/
ā āāā pkg_name4/
ā āāā pkg_name5/
āāā pubspec.yaml
āāā README.md
āāā test/
āāā windows/
I should have this:
āāā assets/
āāā build.yaml
āāā codemagic.yaml
āāā LICENSE.md
āāā apps/
ā āāā my_app/
ā āāā analysis_options.yaml
ā āāā android/
ā āāā ios/
ā āāā l10n.yaml
ā āāā lib/
ā ā āāā main.dart
ā āāā test/
ā āāā windows/
ā āāā pubspec.yaml
āāā melos.yaml
āāā packages/
ā āāā pkg_name1/
ā āāā pkg_name2/
ā āāā pkg_name3/
ā āāā pkg_name4/
ā āāā pkg_name5/
āāā pubspec.yaml
āāā README.md
@Ppito exactly :)
We've strayed from the original topic, but thanks for the advice. š
the same problem #574
Hey there šš¼ I am just facing this issue now
OS: Windows 11
dart
version: 3.2.3 installed through Chocolatey
fvm
version: 2.4.1 installed through the global Dart SDK, and exposes a globally enabled Flutter SDK as default
melos
version: 3.4.0 installed through the global Dart SDK
Case 1: When the root package (the one that includes melos
), only sets the Dart SDK version constraints, running melos bs
fails and a message is shown indicating that the Flutter SDK is required for a couple of sub-packages.
Case 2: When the root package (the one that includes melos
), sets also the Flutter SDK constraints, running melos bs
does work as expected, but the logs state that the actual used deps installation command was flutter pub get
.
Case 2 is the approach I am using now as a workaround.
I consider it a workaround since I would expect the use of the proper SDK (Dart or Flutter) depending on the sub-package pubspec.yaml
environment setup.
I faced the same issue but fixed it by matching the global version of melos to the one in my pubspec.yaml
also set the FLUTTER_ROOT environment variable
Hi, we face with the same issue
FVM for this project:
Flutter 3.16.5 ā¢ channel stable ā¢ https://github.com/flutter/flutter.git
Framework ā¢ revision 78666c8dc5 (8 weeks ago) ā¢ 2023-12-19 16:14:14 -0800
Engine ā¢ revision 3f3e560236
Tools ā¢ Dart 3.2.3 ā¢ DevTools 2.28.4
$ melos bs
Can't load Kernel binary: Invalid kernel binary format version.
melos 4.1.0 doesn't support Dart 2.14.3.
in melos.yaml we have
sdkPath: .fvm/flutter_sdk
But fvm has global version Flutter 2.5.2:
Flutter 2.5.2 ā¢ channel stable ā¢ https://github.com/flutter/flutter.git
Framework ā¢ revision 3595343e20 (2 years, 4 months ago) ā¢ 2021-09-30 12:58:18 -0700
Engine ā¢ revision 6ac856380f
Tools ā¢ Dart 2.14.3
Aka melos does not respect sdkPath
and uses the global flutter
.
There are a few different issues mentioned here. But it seems they are most likely a mismatch on the Flutter/Dart version running the melos command vs the one that is in the .fvm/flutter_sdk
FVM has a command to help force the version that runs the commands called exec
, which executes the command with the flutter version in the path. So you can use fvm exec melos bs
To double-check this, you can do the following:
$ fvm exec dart --version
$ dart --version
These versions are most likely mismatched.
ā @spydon let me know if there is anything I can do to make things easier for you guys.
@leoafarias I'm not sure if there is anything we can do from our side? If the melos binary is installed with another Flutter version I don't think we can change which sdk it executes itself with, only the commands that will be run from within melos. :thinking: There must be other binaries similar to melos that face the same problem when there are multiple versions involved, have you heard of any other?
@spydon FVM has the same problem; as you imagine, FVM can change the SDK that is used to run itself š¤Æ
The only solution I have found is to distribute a compiled binary. This might minimize these problems, and based on some issues I have seen here, it might be the solution for "environment configuration" problems.
If this makes sense to explore, we can talk offline, and I can create an initial PR for this.
@spydon FVM has the same problem; as you imagine, FVM can change the SDK that is used to run itself š¤Æ
Aah yeah, of course!
The only solution I have found is to distribute a compiled binary. This might minimize these problems, and based on some issues I have seen here, it might be the solution for "environment configuration" problems.
You'd have to distribute it outside of pub then I guess? That seems like it would add a lot of maintenance effort. š¤
If this makes sense to explore, we can talk offline, and I can create an initial PR for this.
Yeah, let's have a chat!
Is there an existing issue for this?
Version
>=3.2.0
Description
Hi,
I use fvm to manage my various Flutter versions and until melos version 3.1.1 I had no particular problem with using the sdkPath option in my melos.yml configuration file.
Since I updated melos on 3.2.0 (same problem on 3.4.0) this option no longer works with the message
The Flutter SDK is not available.
.Steps to reproduce
sdkPath: .fvm/flutter_sdk
onmelos.yaml
Expected behavior
The specified SDK path has been found and the command is running.
Screenshots
No response
Additional context and comments
I've looked through the PR and searched the entire project (on tag 3.2.0 and melos-latest), but I can't figure out what caused the problem or how to solve it.
I work on Windows 11 (without WSL), but like I said, everything work fine with melos 3.1.1.
I tried mmany configuration
I also tried to use the env variable
MELOS_SDK_PATH