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

Custom lint immediately crashes #180

Open
dmrickey opened this issue Aug 22, 2023 · 13 comments
Open

Custom lint immediately crashes #180

dmrickey opened this issue Aug 22, 2023 · 13 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@dmrickey
Copy link

The log only includes this

The request analysis.setContextRoots failed with the following error:
RequestErrorCode.PLUGIN_ERROR
ProcessException: The system cannot find the file specified.

  Command: flutter pub get
at:
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:401:33)
#1      Process.start (dart:io-patch/process_patch.dart:38:20)
#2      _runNonInteractiveProcess (dart:io-patch/process_patch.dart:578:18)
#3      Process.run (dart:io-patch/process_patch.dart:49:12)
#4      CustomLintWorkspace.runPubGet (package:custom_lint/src/workspace.dart:829:36)
#5      CustomLintWorkspace.resolvePluginHost (package:custom_lint/src/workspace.dart:804:13)
<asynchronous suspension>
#6      SocketCustomLintServerToClientChannel._startProcess (package:custom_lint/src/v2/server_to_client_channel.dart:165:7)
<asynchronous suspension>
#7      SocketCustomLintServerToClientChannel.init (package:custom_lint/src/v2/server_to_client_channel.dart:116:21)
<asynchronous suspension>
#8      CustomLintServer._maybeSpawnCustomLintPlugin (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:364:5)
<asynchronous suspension>
#9      CustomLintServer._handleAnalysisSetContextRoots.<anonymous closure> (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:328: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:160:22)
<asynchronous suspension>

We were using 0.4.0 and I noticed our custom lints weren't running. So I updated them to the latest 0.5.2 and they're still not working. Does the above tell you what's going on?

@dmrickey dmrickey added the bug Something isn't working label Aug 22, 2023
@rrousselGit
Copy link
Collaborator

There might be something wrong with your development environment.

My understanding is that the terminal's PATH variable does not include Flutter's location.
If you open a new terminal and run flutter pub get, does that work?

@rrousselGit rrousselGit added the question Further information is requested label Aug 24, 2023
@dmrickey
Copy link
Author

Yes, flutter appears to be correctly set up in my path, that successfully fetched dependencies

@rrousselGit
Copy link
Collaborator

In that case that's going to be quite hard for me to debug.

I've never had this error, so without knowing about your environment, that's going to be difficult.

@dmrickey
Copy link
Author

dmrickey commented Aug 28, 2023

I investigated more into the issue. After trashing my update and digging into it more on 0.4.0 it was because multiple of our packages (living side-by-side in the same repo) were referencing different versions of the same dependency which kept custom_lints from launching. The error given in 0.4.0 was much more obvious about this. I don't know if 0.5.2 was having issues because of this, but on 0.4.0 it's working now after making sure everything was using the same versions.

@rrousselGit
Copy link
Collaborator

Sounds like there is a bug if 0.5.2 doesn't catch this or give a proper error message.
But I need to know what caused this.

Could you share the pubspec.yamls and .dart_tool/package_config.json of all the packages in your repo? (before fixing the problem of course)

@dmrickey
Copy link
Author

dmrickey commented Aug 29, 2023

Here's an example from the log before I updated all our dependencies. Just to clarify, this is on 0.4.0. And the packages mentioned in the log aren't direct dependencies, they're dependencies of dependencies (i.e. dart_style is not listed in any of our pubspecs, but it's a dependency of packages that are listed in our pubspecs).

All of our packages rely on a single "shared" package, so I resolved this by defining our dependency versions only in shared, then in every other package I removed the specific version dependency. So only shared is "installing" dependencies and the rest of our packages are just resolving what shared has already installed.

If you need specific examples of our pubspecs beyond this let me know.

I'm not seeing that we have any .dart_tool/package_config.json at all

The request analysis.setContextRoots failed with the following error:
RequestErrorCode.PLUGIN_ERROR
PackageVersionConflictError – Some dependencies with conflicting versions were identified:

Package dart_style:

  • Hosted with version constraint: ^2.2.1
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\dart_style-2.3.1
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "airplay_controller" at "........\Documents\repos\rnm-flutter\plugins\airplay_controller"
  • Hosted with version constraint: ^2.2.1
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\dart_style-2.3.1
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "butter_player" at "........\Documents\repos\rnm-flutter\plugins\butter_player"
  • Hosted with version constraint: ^2.2.1
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\dart_style-2.3.1
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "butter_player_example" at "........\Documents\repos\rnm-flutter\plugins\butter_player\example"
  • Hosted with version constraint: ^2.2.1
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\dart_style-2.3.1
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "data_providers" at "........\Documents\repos\rnm-flutter\packages\data_providers"
  • Hosted with version constraint: ^2.2.1
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\dart_style-2.3.1
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "repositories" at "........\Documents\repos\rnm-flutter\packages\repositories"
  • Hosted with version constraint: ^2.2.1
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\dart_style-2.3.2
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "rnm_flutter" at "........\Documents\repos\rnm-flutter"
  • Hosted with version constraint: ^2.2.1
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\dart_style-2.3.1
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "shared" at "........\Documents\repos\rnm-flutter\packages\shared"

Package vm_service:

  • Hosted with version constraint: >=6.0.1 <12.0.0
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\vm_service-11.7.1
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "airplay_controller" at "........\Documents\repos\rnm-flutter\plugins\airplay_controller"
  • Hosted with version constraint: >=6.0.1 <12.0.0
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\vm_service-11.7.1
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "butter_player" at "........\Documents\repos\rnm-flutter\plugins\butter_player"
  • Hosted with version constraint: >=6.0.1 <12.0.0
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\vm_service-11.7.1
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "butter_player_example" at "........\Documents\repos\rnm-flutter\plugins\butter_player\example"
  • Hosted with version constraint: >=6.0.1 <12.0.0
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\vm_service-11.7.1
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "data_providers" at "........\Documents\repos\rnm-flutter\packages\data_providers"
  • Hosted with version constraint: >=6.0.1 <12.0.0
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\vm_service-11.7.1
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "repositories" at "........\Documents\repos\rnm-flutter\packages\repositories"
  • Hosted with version constraint: >=6.0.1 <12.0.0
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\vm_service-11.7.2
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "rnm_flutter" at "........\Documents\repos\rnm-flutter"
  • Hosted with version constraint: >=6.0.1 <12.0.0
    Resolved with C:\Users\davidrickey\AppData\Local\Pub\Cache\hosted\pub.dev\vm_service-11.7.1
    Used by plugin "custom_lints" at "........\Documents\repos\rnm-flutter\packages\custom_lints" in the project "shared" at "........\Documents\repos\rnm-flutter\packages\shared"

This is not supported. Custom_lint shares the analysis between all packages. As such, all plugins are started under a single process, sharing the dependencies of all the packages that use custom_lint. Since there's a single process for all plugins, if 2 plugins try to use different versions for a dependency, the process cannot be reasonably started. Please make sure all packages have the same version.
You could run the following commands to try fixing this:

@rrousselGit
Copy link
Collaborator

I'm not seeing that we have any .dart_tool/package_config.json at all

You most definitely have some. There's no way to generate an error such as the one linked above without such a file.
You should have one for every pubspec file in your project.

That's what pub get does, it creates this json file.


I'd be curious to see what the error was (the compilation error that preventing plugins from starting).

Do you think you could create a small repo for me to reproduce the error? That would help massively in debugging this.

@jehhxuxu
Copy link

jehhxuxu commented Sep 2, 2023

Just get the error here as well

The Dart VM service is listening on http://127.0.0.1:51581/8JT4cWjeDPw=/ The Dart DevTools debugger and profiler is available at: http://127.0.0.1:51581/8JT4cWjeDPw=/devtools?uri=ws://127.0.0.1:51581/8JT4cWjeDPw=/ws [custom_lint] 2023-09-02T14:45:24.074255 lib/custom_lint_client.dart:13:37: Error: Undefined name 'createPlugin'. [custom_lint] 2023-09-02T14:45:24.074255 {'partner_lints': partner_lints.createPlugin, [custom_lint] 2023-09-02T14:45:24.074255 ^^^^^^^^^^^^ [custom_lint] 2023-09-02T14:45:24.074255 [custom_lint] 2023-09-02T14:45:24.074255 Failed to start pluginsThe request analysis.setContextRoots failed with the following error: RequestErrorCode.PLUGIN_ERROR Bad state: Failed to start the plugins. at: #0 SocketCustomLintServerToClientChannel._checkInitializationFail.<anonymous closure> (package:custom_lint/src/v2/server_to_client_channel.dart:227:11) <asynchronous suspension> #1 Future.any.onValue (dart:async/future.dart:615:5) <asynchronous suspension>

❯ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):em Ruby 2.6.3 F stable 14:47:46
[✓] Flutter (Channel stable, 3.13.2, on macOS 13.4.1 22F770820d darwin-x64, locale en-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] IntelliJ IDEA Community Edition (version 2023.1.3)
[✓] VS Code (version 1.81.1)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!

@rrousselGit
Copy link
Collaborator

According to this error, you did not define a createPlugin function in lib/<your_package_name>.dart

@jehhxuxu
Copy link

jehhxuxu commented Sep 2, 2023

This? I was just following your fluttercon talk and trying to re-create the same code

Screenshot 2023-09-02 at 16 01 40 Screenshot 2023-09-02 at 16 01 49

@rrousselGit
Copy link
Collaborator

Yes. Make sure that this createPlugin is in the right location.
It is imported with package:<your_package_name>/<your_package_name>.dart', so at the root of the lib folder

From that error, it sounds like you defined it in a different place. Maybe it's in the lib/src folder

@jehhxuxu
Copy link

jehhxuxu commented Sep 2, 2023

In fact, my mistake, the main file was main.dart... I'm sorry =/
Rename the file and it's working... Thank you for your time

@rrousselGit
Copy link
Collaborator

No worries, the error isn't super clear :)
There are plans to make this smoother #96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants