-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
we should detect the user's PATH env var and use that when we shell out to the flutter tool #601
Comments
We should also handle the case where the Android dev tools aren't in the user's path at all. For me, they're not, since I tend to use bash aliases for command I run regularly, instead of adding them to my path. It looks like I did set ANDROID_HOME, though. |
The flutter command has some functionality for that -
|
It looks like currently we don't use the PATH or environment variables at all. We find the Flutter SDK from the globally configured Dart SDK, under the assumption that the Dart SDK is in $FLUTTER_HOME/bin/cache/dart-sdk. If it's not, the getFlutterSdk() method returns null. Sometimes we handle that, other times it silently does nothing. [1] It seems like we want the Flutter SDK and the Dart SDK to be consistent, so we should help the user set their Dart SDK correctly, and then everything works? At least, we need to show an error when the current Dart SDK is not within a Flutter directory, explaining what to change it to. I'm not sure what the UI for this should look like. What are our options for displaying errors? (Also, the DartSdk plugin currently doesn't have a per-project Dart SDK setting, but I guess that is fixed in 2017.1 [2]) [1] Code references: |
It looks like this should be the job of: SdkConfigurationNotificationProvider.createNotificationPanel(). However, I set a breakpoint and changed the Dart SDK, and it didn't stop there. |
+1!
Some good UI options are showing a toast (an IntelliJ Notification), and displaying a butter bar at the top of the current editor. Totally correct that IntelliJ isn't using |
If what's being described here is an inability to access certain environment variables in IntellIj, I've worked around this for years for Android by using
|
Just for context, many users are hitting this on gitter. |
What is gitter? How do I read more about this? |
gitter: https://gitter.im/flutter/flutter :) Just providing context for the amount of impact of the issue - |
I haven't reproduced this yet. I have a shell open with PATH='/usr/bin:/bin' and Flutter commands work fine so far, so I'm skeptical we need to set the PATH. If we do, it would be good to know which Flutter command cares about this. |
Today's issue on gitter was not this bug, it's #646. |
Perhaps chatting by VC? I have seen this is previous tools. I haven't encountered it myself w/ the flutter plugin, but haven't specifically tried to repro, and the issues symptoms people have reported sounds a lot like this issue. |
I think what would help most is seeing more user reports, if you remember where they were. |
Flutter finds Android home here: I think I wasn't able to reproduce because I had ANDROID_HOME set in ~/.bash_profile, and that's sufficient. |
@skybrian, ping - is this in progress? We're hoping to release 0.1.9 tomorrow |
No progress yet but I'm working on it this afternoon/evening. |
Update: I don't think this is going to make the release. |
On second thought, I'm not sure there's anything to do. I was able to verify that ANDROID_HOME is not set within the IDEA Java process when run from the dock, but it is set by the time the 'flutter' command starts when I run "flutter doctor" from within IDEA. How does this happen? It appears that IDEA already implements a similar workaround for Macs. In the GeneralCommandLine class, there is a myParentEnvironmentType field which is set to ParentEnvironmentType.CONSOLE by default. When this is set, EnvironmentUtil.getEnvironmentMap() gets run. The ShellEnvReader class calls a helper script, which is at /Applications/IntelliJ\ IDEA\ CE.app/Contents/bin/printenv.py on my Mac. As long as we use GeneralCommandLine everywhere, and don't change the default, I think the environment should be set up correctly. If not, I need to figure out what our workaround code should do that IDEA's workaround code doesn't already do. |
Thanks for investigating! Do you know if they have similar workaround code for linux? (but from looking here: https://github.com/JetBrains/intellij-community/blob/master/platform/util/src/com/intellij/util/EnvironmentUtil.java#L164, it seems like they do) I wonder what the user reports were running into? Perhaps they started IntelliJ, then configured their PATH? If I recall correctly, I think two separate github or gitter issues were resolved by closing IntelliJ and restarting it from the cli. |
I think just restarting should do it. The environment is only read once and cached. (There is a static block at the top of the file.) |
OK, thanks again for looking into this. I think we should add a FAQ or troubleshooting item about this on our docs; that the PATH is read once at startup, and if devices show up when running /cc @mit-mit |
Looks like there is a known issue for Linux: |
I filed a bug for the issue in EnvironmentUtil: |
👍 |
Closing - the fix for this will happen upstream. |
I was hit by this (and #634) with AS 3.0 and just installed official beta. There is NO mention of this glitch within documentation. For a quick workaround I set flutter config --android-studio-dir and --android-sdk manually as hinted by above discussion but it costed me finding #634 and this, both closed, issues. As there is bold advise on the install doc to run doctor twice the quick fix is possible: -- |
In many OSes, when the user launches a GUI app from a launcher (OSX dock for example) the shell used is not necessarily the user's default shell. The env variables they had set up won't be visible to that GUI app. When we then shell out to something like the
flutter
tool, it won't be able to detect the location of the android deve tools, or other things that we'd find on aPATH
.See related (Dart) code here: https://github.com/dart-atom/atom.dart/blob/master/lib/node/process.dart#L190.
The text was updated successfully, but these errors were encountered: