Skip to content
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

Can't run Flutter project if it's within a Bazel directory #4825

Closed
rohansingh opened this issue Sep 14, 2020 · 16 comments · Fixed by #4886
Closed

Can't run Flutter project if it's within a Bazel directory #4825

rohansingh opened this issue Sep 14, 2020 · 16 comments · Fixed by #4886
Milestone

Comments

@rohansingh
Copy link

rohansingh commented Sep 14, 2020

I have a Flutter project that's within a Bazel directory. It's not built by Bazel in any way, but it happens to be in a monorepo that uses Bazel for most other things.

Running and debugging from within Android Studio used to work fine, but is now broken. Trying to launch main.dart results in an error:

Entrypoint isn't within a Flutter pub root.

Looking at Preferences > Languages & Frameworks > Flutter shows that the Flutter SDK path has changed to /Users/rohan/tidbyt/null <set by bazel project>. That isn't a valid path on my machine. Resetting the setting here doesn't seem to do anything.

I have a hunch that this is related to #4735 (/cc @helin24 @jacob314). My guess is that that broke the IntelliJ plugin for Flutter projects in Bazel directories outside of Google.

Steps to Reproduce

  1. Have a Flutter project that's inside a Bazel workspace. (not at Google)
  2. Try to run the project from within Android Studio

Version info

[✓] Flutter (Channel unknown, 1.20.2, on Mac OS X 10.15.6 19G2021, locale en-US)
    • Flutter version 1.20.2 at /opt/flutter
    • Framework revision bbfbf1770c (5 weeks ago), 2020-08-13 08:33:09 -0700
    • Engine revision 9d5b21729f
    • Dart version 2.9.1

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/rohan/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    ✗ Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions.

[✓] Xcode - develop for iOS and macOS (Xcode 11.7)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.7, Build version 11E801a
    • CocoaPods version 1.9.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 49.0.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.49.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.14.1

[✓] Connected device (3 available)
    • Pixel 3 (mobile) • 8BWX1G3QH  • android-arm64  • Android 11 (API 30)
    • Web Server (web) • web-server • web-javascript • Flutter Tools
    • Chrome (web)     • chrome     • web-javascript • Google Chrome 85.0.4183.102

! Doctor found issues in 1 category.
@rohansingh
Copy link
Author

rohansingh commented Sep 14, 2020

I guess my hunch about #4735 was wrong actually, since that's only on master and hasn't even been released. Apologies.

@rohansingh
Copy link
Author

Switching to the dev channel doesn't seem to fix this either.

@helin24
Copy link
Member

helin24 commented Sep 14, 2020

Hmmm #4735 should be merged, but I think we may have missed it in the list of changes for August. Can you download v48.0.4 from July and try that out? https://plugins.jetbrains.com/plugin/9212-flutter/versions (You can use a downloaded plugin by going to Preferences -> Plugins -> (settings button) -> Install Plugins from Disk)

@helin24 helin24 added the waiting for customer response Auto-close if no response label Sep 14, 2020
@rohansingh
Copy link
Author

rohansingh commented Sep 14, 2020

Unfortunately I don't seem to be able to install any Flutter plugin version from disk.

Screen Shot 2020-09-14 at 12 56 02

This is with Android Studio 4.0.1 on macOS. I've tried completely blowing away and reinstalling Android Studio, but unfortunately that hasn't had any effect 😐

Also tried several different versions of the plugin, but same result.

@no-response no-response bot removed the waiting for customer response Auto-close if no response label Sep 14, 2020
@helin24
Copy link
Member

helin24 commented Sep 14, 2020

I'm sorry, I recommended the wrong version! I was able to install v48.0.2 of the plugin onto my Android Studio 4.0, can you try that one instead?

@rohansingh
Copy link
Author

Ah, I see, I didn't realize that certain versions only work with certain build numbers.

Anyway, I did as you asked and installed v48.0.2, and it worked. I am able to build and run my Flutter app again.

@helin24
Copy link
Member

helin24 commented Sep 14, 2020

Thanks for checking; it's likely there is an issue with our bazel check, so we'll look into it.

Last thing, can you send along your log? Help -> show log in finder

@helin24 helin24 added this to the On Deck milestone Sep 14, 2020
@rohansingh
Copy link
Author

Here's my idea.log. It captures multiple launches of the IDE, with both v48.0.2 (working) and v49.0.2 (broken).

@jacob314
Copy link
Contributor

It is a bug that we are detecting that your project is a bazel project. We should only be detecting that google3 bazel projects are bazel projects. Did you happen to add a flutter.json file or in a previous version of the plugin check the checkbox to indicate that your project is a flutter bazel project? We've removed that checkbox but perhaps we still have logic checking whether you have manually indicated the project was bazel that is causing problems.

@rohansingh
Copy link
Author

It's certainly possible that I checked a box like that. However I can't seem to find any flutter.json file in my project directory currently. I've also tried deleting everything that I can think of:

rm -rf .idea
rm ~/Library/Preferences/com.google.android.studio.plist
rm -Rf ~/Library/Application\ Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
rm -Rf ~/Library/Caches/AndroidStudio*

@jacob314
Copy link
Contributor

it is a bug that we are classifying the project as Bazel. Hopefully the issue is just that somewhere in our code we are still using the old confusing manually configurable setting to indicate your project is bazel.

@rohansingh
Copy link
Author

@jacob314 Makes sense, but any idea where that setting would be persisted?

@xiaodongw
Copy link

I'm having the same issue. My repository is a mono repo with Kotlin, C++ and Flutter projects. I have the Flutter project in one folder and a C++ Bazel project in another folder, they are not related, but Intellij recognizes the bazel project and configures the Flutter SDK to that Bazel project, which even is not a Flutter project.

Screenshot-20200915215556-1990x452

@helin24
Copy link
Member

helin24 commented Sep 16, 2020

Thanks for the info (and the patience). I'm not finding a particular setting that can be changed to indicate a bazel project, but I'll look into the checks within the plugin. In the meantime, I recommend using an older version of the plugin, 48.0 or earlier if you can.

@helin24
Copy link
Member

helin24 commented Sep 23, 2020

@rohansingh is your setup something like this, and does it have a WORKSPACE file near the top level?

  • top-level monorepo/
    • WORKSPACE
    • non_flutter_dir_using_bazel/
    • flutter_project_dir/
      • pubspec.yaml
      • main.dart

Our code checks for the presence of a WORKSPACE file to recognize if a project is bazel, before checking for a pubspec.yaml file. We may be able to fix the problem by reversing the order of these checks.

@rohansingh
Copy link
Author

@helin24 Yup, that's exactly how my project is setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants