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

Error when removing Flutter dependencies from pubspec.yaml in specific modules #238

Open
kensamare opened this issue Mar 19, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@kensamare
Copy link

I have the following structure in a project.

- project
  - packages
    - data
    - domain
    - state

Added to pubspec.yaml for all packages:

custom_link: 0.6.2
my_lint: 1.0.0

And if you remove from one package all dependencies related to flutter, for example domain:

name: domain
description: "Domain"
version: 0.0.1
homepage:

environment:
  sdk: '>=3.2.3 <4.0.0'

dependencies:

dev_dependencies:
  custom_lint: 0.6.2
  my_lint: 1.0.0

And in other packages I leave everything as is, then I get an error:

The request analysis.setContextRoots failed with the following error:
RequestErrorCode.PLUGIN_ERROR
ProcessException: No such file or directory
  Command: flutter pub get

Sometimes:

The request analysis.setContextRoots failed with the following error:
RequestErrorCode.PLUGIN_ERROR
UnimplementedError

However, this problem is observed only in Android Studio, when using VS Code this problem is not observed

@kensamare kensamare added the bug Something isn't working label Mar 19, 2024
@rehlma
Copy link

rehlma commented May 16, 2024

I had the same error with a slightly different setup and I could solve it.

- project/package
  - lib
  - analysis_options.yaml
  - pubspec.yaml
  - package_1
    - lib
    - analysis_options.yaml
    - pubspec.yaml
  - my_lint
    - lib
    - pubspec.yaml
    - example
      - lib
      - analysis_options.yaml
      - pubspec.yaml

At first I added my_lint to the root, package_1 and example package like this and I always got that error with IntelliJ.

dev_dependencies:
  custom_lint: 0.6.2
  my_lint:
    path: ./my_lint

and

analyzer:
  plugins:
    - custom_lint

Then I noticed that the issues is solved once I ensure that the analyzer plugin is set just once in my root package and not in every analysis_options.yaml And only add the dev_dependencies to all packages where you intend to use your my_lint

I hope this might help you.

@rrousselGit
Copy link
Collaborator

Custom_lint currently does not support modifying dependencies while it is running.

If you edit your pubspec.yaml in ways that impact lints, you have to restart custom_lint somehow (such as through restarting your IDE).
Hence that exception.

I don't know a way to solve this in a more convenient way for now, because custom_lint has no way to restart itself.

@kensamare
Copy link
Author

I had the same error with a slightly different setup and I could solve it.

- project/package
  - lib
  - analysis_options.yaml
  - pubspec.yaml
  - package_1
    - lib
    - analysis_options.yaml
    - pubspec.yaml
  - my_lint
    - lib
    - pubspec.yaml
    - example
      - lib
      - analysis_options.yaml
      - pubspec.yaml

At first I added my_lint to the root, package_1 and example package like this and I always got that error with IntelliJ.

dev_dependencies:
  custom_lint: 0.6.2
  my_lint:
    path: ./my_lint

and

analyzer:
  plugins:
    - custom_lint

Then I noticed that the issues is solved once I ensure that the analyzer plugin is set just once in my root package and not in every analysis_options.yaml And only add the dev_dependencies to all packages where you intend to use your my_lint

I hope this might help you.

Thank you very much. Yes indeed in this variation the linter shows errors. However, fixes inside packages are not available. Are there any options for how to solve this?

@kensamare
Copy link
Author

Custom_lint currently does not support modifying dependencies while it is running.

If you edit your pubspec.yaml in ways that impact lints, you have to restart custom_lint somehow (such as through restarting your IDE). Hence that exception.

I don't know a way to solve this in a more convenient way for now, because custom_lint has no way to restart itself.

Dependencies do not change during development. This error appears from the start of the IDE, the linter simply cannot start. If necessary, I can provide a repository where there is an opportunity to repeat this error.

@kensamare
Copy link
Author

@rrousselGit This bug only appears in Android Studio and in VS Code everything works fine.

@rrousselGit
Copy link
Collaborator

Dependencies do not change during development. This error appears from the start of the IDE, the linter simply cannot start. If necessary, I can provide a repository where there is an opportunity to repeat this error.

The UnimplementedError is when a dependency changes.

The other error, I'm unfamiliar with it. So I'd require a specific reproduction for that.
Do you mind making a git repository for it?

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

3 participants