Open mit-mit opened 6 years ago
Another approach would be integrating Flutter into package managers. Then users wouldn't need to do one off path configurations.
Some tools offer options for installing into system directories that are already on the user's path, like /usr/local/bin/
. These are generally privileged locations - on macos they require the user to ok the write w/ a system prompt. VSCode / IntelliJ / Android Studio all have menu options to install into the system path, and write small scripts into usr/local/bin. Here's the /usr/local/bin/code script:
#!/usr/bin/env bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
function realpath() { /usr/bin/python -c "import os,sys; print os.path.realpath(sys.argv[1])" "$0"; }
CONTENTS="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
ELECTRON="$CONTENTS/MacOS/Electron"
CLI="$CONTENTS/Resources/app/out/cli.js"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?
So, from the flutter
cli, we'd do something which would offer to install it into a system path, and write a trampoline script there which would invoke <flutter-sdk>/bin/flutter
.
another approach would be integrating Flutter into package managers
That would work as well, and be very nice for package managers that are broadly used (brew in the mac, ...).
Flatpak sdk extensions would also solve this - https://blogs.gnome.org/chergert/2018/01/20/builder-happenings-for-january/
Some tools offer options for installing into system directories that are already on the user's path
I don't know if there's an equiv for this on Windows (most things tend to modify PATH rather than putting links into existing places).
v2.10.0 (currently beta) of Dart Code now gives the user a Locate SDK
option when this message appears with a folder picker which I expect will somewhat resolve these issues. My preference is still to detect from PATH (it's self-maintaining, unlike writing the SDK path to settings) but based on the issues raised, I think it's giong to be complicated (for ex. there are people that have flutter
in their path yet when the open Code, it gets a different path (for example some custom shells handle path differently).
FWIW, Dart Code handles this better now:
The Locate SDK
button opens a folder picker and lets the user browse to their SDK (and validates its an SDK before writing it to global settings).
There's a remaining bug I found (https://github.com/Dart-Code/Dart-Code/issues/693) when we don't find Flutter but do find Dart, which is fixed for next version.
It would be good if doctor could check for this.
It would be even better if the flutter tool could offer to add to path on behalf of the user.
The main issue that was coming up was from people that had added to PATH
but then either didn't reboot (or whatever is required for it to get to Code
) or had just set the PATH
in a way that it only applied to their shell. I don't think either of the above would address this (since from within the terminal, it seems like it's all good - the fact that flutter doctor
works suggests that to the process it'll seem like it is definitely on PATH
).
So, unless this is affecting other IDEs (and there'a fix that could address those main two issues mentioned above), I'm not sure if there's much worth doing here.
Since adding the Locate SDK
button to the message (+ suggesting people restart) and the zip files with a the flutter_console.bat
I haven't really had any complaints about paths at all. I don't know if this is still an issue we feel we need to do anything about?
Similar to #8029
Related to #9401
Steps to Reproduce
We are seeing lots of upstream issues in the IDEs boiling down to the root issue of users not having flutter correctly in path (for example, https://github.com/flutter/flutter/issues/15066, https://github.com/Dart-Code/Dart-Code/issues/633).
It would be good if doctor could check for this.
It would be even better if the flutter tool could offer to add to path on behalf of the user.