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

analysis.setContextRoots failed - RequestErrorCode.PLUGIN_ERROR ProcessException: / No such file or directory / Command: flutter pub get #270

Open
woteska opened this issue Sep 10, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@woteska
Copy link

woteska commented Sep 10, 2024

Describe the bug

The lint errors do not appear at all in my Android Studio Dart Analysis tab nor in the source code highlighted, and custom_lint.log contains the following error (it does not make any sense to me - flutter pub get exceeds sucessfully):

The request analysis.setContextRoots failed with the following error:
RequestErrorCode.PLUGIN_ERROR
ProcessException: No such file or directory
  Command: flutter pub get
at:
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:402:33)
#1      Process.start (dart:io-patch/process_patch.dart:38:20)
#2      _runNonInteractiveProcess (dart:io-patch/process_patch.dart:579:18)
#3      Process.run (dart:io-patch/process_patch.dart:49:12)
#4      CustomLintWorkspace.runPubGet (package:custom_lint/src/workspace.dart:772:36)
#5      CustomLintWorkspace.resolvePluginHost (package:custom_lint/src/workspace.dart:765:11)
#6      SocketCustomLintServerToClientChannel._startProcess (package:custom_lint/src/v2/server_to_client_channel.dart:151:24)
#7      SocketCustomLintServerToClientChannel.init (package:custom_lint/src/v2/server_to_client_channel.dart:110:22)
#8      CustomLintServer._maybeSpawnCustomLintPlugin (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:394:25)
<asynchronous suspension>
#9      CustomLintServer._handleAnalysisSetContextRoots.<anonymous closure> (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:341:9)
<asynchronous suspension>
#10     PendingOperation.run (package:custom_lint/src/async_operation.dart:22:14)
<asynchronous suspension>
#11     CustomLintServer._handleRequest (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:173:22)
<asynchronous suspension>

If I run dart run custom_lint, I see the lint issues in the console output (as expected).

To Reproduce

IDE:

Android Studio Koala Feature Drop | 2024.1.2
Build #AI-241.18034.62.2412.12266719, built on August 22, 2024
Runtime version: 17.0.11+0-17.0.11b1207.24-11852314 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 14.6.1
GC: G1 Young Generation, G1 Old Generation
Memory: 8192M
Cores: 10
Metal Rendering is ON
Registry:
  ide.instant.shutdown=false
  debugger.new.tool.window.layout=true
  ide.experimental.ui=true
  dart.macros.support=false
Non-Bundled Plugins:
  Dart (241.18808)
  com.intellij.lang.jsgraphql (241.14494.150)
  dev.gabrielchl.intellij-pets (0.1.9)
  io.flutter (81.0.2)

IDE plugins:
Dart Plugin: 241.1880
Flutter Plugin: 81.0.2

  **custom_lint**:
    dependency: "direct dev"
    description:
      name: custom_lint
    source: hosted
    version: "0.6.7"
  **custom_lint_builder**:
    dependency: transitive
    description:
      name: custom_lint_builder
    source: hosted
    version: "0.6.7"
  **custom_lint_core**:
    dependency: transitive
    description:
      name: custom_lint_core
    source: hosted
    version: "0.6.5"
  **analyzer**:
    dependency: "direct overridden"
    description:
      name: analyzer
    source: hosted
    version: "6.7.0"
  **analyzer_plugin**:
    dependency: transitive
    description:
      name: analyzer_plugin
    source: hosted
    version: "0.11.3"  
[...]
sdks:
  dart: ">=3.5.1 <4.0.0"
  flutter: ">=3.24.0"

Full pubspec.lock (uploaded with .log extension as github does not allow to upload files ending with .lock):
pubspec.lock.log

Flutter doctor

[✓] Flutter (Channel stable, 3.24.1, on macOS 14.6.1 23G93 darwin-arm64, locale en-HU)
    • Flutter version 3.24.1 on channel stable at /Users/asd/fvm/versions/3.24.1
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5874a72aa4 (3 weeks ago), 2024-08-20 16:46:00 -0500
    • Engine revision c9b9d5780d
    • Dart version 3.5.1
    • DevTools version 2.37.2
    • Pub download mirror https://example.com/artifactory/api/pub/pub

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/asd/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/asd/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] IntelliJ IDEA Community Edition (version 2024.1.6)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

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

[✓] Connected device (4 available)
    • iPhone 15 Pro Max (mobile)      • 2D27068A-15CA-4C4A-BCAE-BB7CD572CA88 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 14.6.1 23G93 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 128.0.6613.120

[✓] Network resources
    • All expected network resources are available.

• No issues found!

I attach the Android Studio Analysis Server Diagnostics report as well:
dart_analyzer_diagnostics_report.json

analysis_options.yaml:

include: package:analysis/lint2.yaml

analyzer:
  plugins:
    - custom_lint
  exclude:
    - eg1
    - eg2

custom_lint:
  rules:
    - asd1: false
    - asd2: false

Resolve attemptions

I tried to upgraded-downgraded the Flutter SDK, analyzer.
I also tried to run flutter clean, flutter pub cache clean.
But wasn't able to make it work, only if I downgrade custom_lint to 0.6.6 or 0.6.5.

Expected behavior

I should see the lint errors in Dart Analysis tab in Android Studio, and I also should see the errors in the source code highlighted.

Additional notes

It perfectly works with Visual Studio Code IDE as expected.

Version: 1.93.0 (Universal)
Commit: 4849ca9bdf9666755eb463db297b69e5385090e3
Date: 2024-09-04T13:02:38.431Z
Electron: 30.4.0
ElectronBuildId: 10073054
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Darwin arm64 23.6.0
Name: Flutter
Id: Dart-Code.flutter
Description: Flutter support and debugger for Visual Studio Code.
Version: 3.96.0
Publisher: Dart Code
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
Name: Dart
Id: Dart-Code.dart-code
Description: Dart language support and debugger for Visual Studio Code.
Version: 3.96.0
Publisher: Dart Code
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code
Screenshot 2024-09-10 at 16 19 06 Screenshot 2024-09-10 at 16 19 32 Screenshot 2024-09-10 at 16 20 11 Screenshot 2024-09-10 at 16 25 00

I am not sure the issue can regards to macros, but they are disabled in my IDE because of a previous issue:
Screenshot 2024-09-10 at 16 29 11

@woteska woteska added the bug Something isn't working label Sep 10, 2024
@EricSchlichting
Copy link

EricSchlichting commented Sep 10, 2024

We are getting this exact same issue as well.

Seems like tempDir might be invalid?

 /// Run "pub get" in the client project.
  Future<void> runPubGet(Directory tempDir) async {
    final command = isUsingFlutter ? 'flutter' : 'dart';

    final result = await runProcess(
      command,
      const ['pub', 'get'],
      stdoutEncoding: utf8,
      stderrEncoding: utf8,
      workingDirectory: tempDir.path,
      runInShell: platformIsWindows,
    );
    if (result.exitCode != 0) {
      throw Exception(
        'Failed to run "pub get" in the client project:\n'
        '${result.stdout}\n'
        '${result.stderr}',
      );
    }
  }

flutter pub get works when run in command line.

This is the tempDir it is trying to use that does not exist: '/var/folders/dm/xz10cgy114g5plf8c02h19mr0000gq/T/custom_lint_clientn65kUQ'

@EricSchlichting
Copy link

@rrousselGit I pulled down the latest from git and pointed my project at it. FWIW the analyzer plugin started working when I specified the full path to my flutter command:

final command = isUsingFlutter ? '/Users/Eric.Schlichting/Library/Flutter/bin/flutter' : 'dart';

Seems like something change with the resolution of that command. Maybe the path isn't setup properly in the process anymore.

@woteska
Copy link
Author

woteska commented Sep 10, 2024

@rrousselGit I pulled down the latest from git and pointed my project at it. FWIW the analyzer plugin started working when I specified the full path to my flutter command:

final command = isUsingFlutter ? '/Users/Eric.Schlichting/Library/Flutter/bin/flutter' : 'dart';

Seems like something change with the resolution of that command. Maybe the path isn't setup properly in the process anymore.

If I downgrade and pin to 0.6.5 or 0.6.6 it works again.
Can you test it?
custom_lint: 0.6.6

@EricSchlichting
Copy link

@woteska that works for us as well. Thank you!

@josh-burton
Copy link

Downgrading worked for me too. I'm using fvm to manage flutter versions - I wonder if its related.

@pcpenpal
Copy link

pcpenpal commented Oct 26, 2024

I'm experiencing this issue on Android Studio + macOS environment. Here's something I found out.

macOS sets the PATH environment value to /usr/bin:/bin:/usr/sbin:/sbin for new processes launched by Finder or Launchpad and so on. Android Studio launched through JetBrains Toolbox seems to have the same value. And the Dart Analysis Server launched by Android Studio is also the same and it can be checked by accessing the diagnostics web page. As far as I know, according to the installation guide of Flutter, in most cases the flutter binary is not in /usr/bin but somewhere in the home directory like ~/flutter/bin. So custom_lint is unable to find flutter.

As a workaround I tried to symlink e.g. sudo ln -s ~/flutter/bin/flutter /usr/bin/flutter but failed because of System Integrity Protection. So I think macOS users are unable to use custom_lint for now.

I think there are two approaches to solve this problem.

  1. Making the flutter or dart binary path configurable.
  2. Launching the process with runInShell: true to read the shell profile and set the PATH variable properly.
    • However, since the current implementation of Process.run executes /bin/sh, macOS users who only use .zprofile wouldn't be able to solve the problem with this approach.

Or maybe the Dart Analysis Server could be changed to pass the dart binary path to plugins.

Skyost added a commit to Skyost/OpenAuthenticator that referenced this issue Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants