flutter icon indicating copy to clipboard operation
flutter copied to clipboard

[proposal] allow `dart` installation outside flutter folder and/or symlink

Open iapicca opened this issue 2 years ago • 2 comments

Description

in some case there is a pre-existing version of dart installed on the dev machine

to reproduce

  1. install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

~~it may throw right now, but works (see issue)~~

  1. install dart-sdk
brew install dart-sdk
  1. update path
export PATH="$PATH":"$HOME/.pub-cache/bin"
export PATH="$PATH":"$HOME/fvm/default/bin"
  1. install fvm
dart pub global activate fvm
  1. install flutter via fvm
fvm use stable
  1. run flutter doctor -v

expected result

before flutter 3.7, there was no warning

actual result

[!] Flutter (Channel stable, 3.7.0, on macOS 13.2 22D49 darwin-arm64, locale en-EE)
    • Flutter version 3.7.0 on channel stable at /Users/yakforward/fvm/versions/stable
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.19.0/libexec/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/yakforward/fvm/versions/stable. Consider adding
      /Users/yakforward/fvm/versions/stable/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b06b8b2710 (4 days ago), 2023-01-23 16:55:55 -0800
    • Engine revision b24591ed32
    • Dart version 2.19.0
    • DevTools version 2.20.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to
      perform update checks and upgrades.

note

adding export PATH="$PATH":"$HOME/fvm/versions/stable/bin" to path doesn't change the error message, there are just 2 darts now :)

Proposal

allow dart installation outside flutter folder and possibly just symlink current dart version in the flutter folder if already exists and version matches

iapicca avatar Jan 27 '23 13:01 iapicca

Thanks I can reproduce this issue with 3.7. In fact, I've been living with it for a while since triaging requires me to mostly work on master :D

exaby73 avatar Jan 27 '23 15:01 exaby73

adding export PATH="$PATH":"$HOME/fvm/versions/stable/bin" to path

The doctor validator is suggesting export PATH="$HOME/fvm/versions/stable/bin:$PATH", not the other way around.

Also, the doctor validator is not disallowing you to have multiple versions of Dart, it's just giving you a warning that, for example, calling dart format on your Flutter app code may not do what you think.

christopherfujino avatar Jan 27 '23 23:01 christopherfujino

adding export PATH="$PATH":"$HOME/fvm/versions/stable/bin" to path

The doctor validator is suggesting export PATH="$HOME/fvm/versions/stable/bin:$PATH", not the other way around.

as I understand the warning

 ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.19.0/libexec/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/yakforward/fvm/versions/stable. Consider adding
      /Users/yakforward/fvm/versions/stable/bin to the front of your path.

it sees my homebrew installation and asks me to "Consider adding /Users/yakforward/fvm/versions/stable/bin to the front of your path." which I did export PATH="$PATH":"$HOME/fvm/versions/stable/bin" with no changes in the message, so I assume that it is asking me to replace homebrew's dart with flutter's dart

Also, the doctor validator is not disallowing you to have multiple versions of Dart, it's just giving you a warning that, for example, calling dart format on your Flutter app code may not do what you think.

sure, no problem about that, I just wonder if it would be possible for flutter to "scan" the system for a dart installation and, if the installed version is compatible etc..., instead of make another copy, just use that one

iapicca avatar Jan 29 '23 12:01 iapicca

adding export PATH="$PATH":"$HOME/fvm/versions/stable/bin" to path

The doctor validator is suggesting export PATH="$HOME/fvm/versions/stable/bin:$PATH", not the other way around.

as I understand the warning

 ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.19.0/libexec/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/yakforward/fvm/versions/stable. Consider adding
      /Users/yakforward/fvm/versions/stable/bin to the front of your path.

it sees my homebrew installation and asks me to "Consider adding /Users/yakforward/fvm/versions/stable/bin to the front of your path." which I did export PATH="$PATH":"$HOME/fvm/versions/stable/bin" with no changes in the message, so I assume that it is asking me to replace homebrew's dart with flutter's dart

Right, but by adding something to the END of your path when $PATH already contains dart, you're not changing anything :) (the $PATH variable is parsed from left to right, and then as soon as a match is found it stops searching).

Also, the doctor validator is not disallowing you to have multiple versions of Dart, it's just giving you a warning that, for example, calling dart format on your Flutter app code may not do what you think.

sure, no problem about that, I just wonder if it would be possible for flutter to "scan" the system for a dart installation and, if the installed version is compatible etc..., instead of make another copy, just use that one

flutter already uses the right dart (there's a lot of complicated logic to find where you cloned the Flutter repo and then check inside its cache for the Dart SDK). This doctor validator is only warning you that invoking dart from the terminal on your app code may not do what you expect.

christopherfujino avatar Jan 30 '23 18:01 christopherfujino

Closing as a duplicate of https://github.com/flutter/flutter/issues/115651

christopherfujino avatar Feb 07 '23 21:02 christopherfujino

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

github-actions[bot] avatar Mar 03 '23 12:03 github-actions[bot]