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

Analyzer plugin should support relative path dependencies #35281

Open
a14n opened this issue Nov 28, 2018 · 5 comments
Open

Analyzer plugin should support relative path dependencies #35281

a14n opened this issue Nov 28, 2018 · 5 comments
Labels
analyzer-plugin area-devexp Developer Experience related issues (DevTools, IDEs, Analysis Server, completions, refactoring, etc) P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@a14n
Copy link
Contributor

a14n commented Nov 28, 2018

(with dart-2.1.0)
Creating a analysis server plugin I used a relative path dependency in the bootstrap package. When I tried to use the plugin nothing worked (no analysis error, no error that the plugin loading failed).

As the bootstrap package is copied in ~/.dartServer/.plugin_manager the relative path is wrong from this place.

Perhaps the path dependencies should be rewriten to absolute path when the bootstrap package is set up.

@bwilkerson
Copy link
Member

Possibly so, but I'm not sure I understand the use case. The bootstrap package is expected to be a package like any other, referencing only code within itself or within other packages that can be referenced via a 'package:' URI. Under what condition(s) does this model fail to be sufficient?

@a14n
Copy link
Contributor Author

a14n commented Nov 28, 2018

I wanted to play with the plugin system so I created a simple plugin based on the angular plugin. So I had something like:

my_plugin
 lib
  starter.dart
 tools
  analyzer_plugin
   bin
    plugin.dart
   pubspec.yaml
 pubspec.yaml

where my my_plugin/tools/analyzer_plugin/pubspec.yaml is:

name: my_plugin_loader
version: 0.0.0
description: Self-loader of the plugin.
dev_dependencies:
  my_plugin:
    path: ../..

@bwilkerson
Copy link
Member

And you can't reference 'my_plugin' via a package: URI because it hasn't been published yet. But you should be able to work around it for now by using an absolute path. You'll need to update it before publishing (assuming you do), and if you ever move the package on your file system, but it should otherwise be fine.

@bwilkerson bwilkerson added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-enhancement A request for a change that isn't a bug analyzer-plugin labels Nov 28, 2018
@stereotype441 stereotype441 added the P2 A bug or feature request we're likely to work on label Nov 28, 2018
@spkersten
Copy link
Contributor

We have an analyzer plugin with team-specific rules that we don't want to publish in a mono-repo with out code. Since the repo is used on many different machines, using an absolute path is inconvenient. (Now we have a bootstrap script that makes the path absolute.)

@RohitSaily
Copy link
Contributor

RohitSaily commented Jan 12, 2025

A simple workaround is to have the packages (the bootstrap package and any it will depend on via relative paths) in the same Git repository. In this case, a relative path can be used to specify the location of dependencies within the Git repository.

The trade-offs of this approach are as follows:

  1. The bootstrap package will only use the most recent committed version of the dependencies.
  2. Explicit upgrading of the depended-on packages may need to be done to use the latest committed version.
  3. Transitive dependencies that are specified using relative paths will likely only work if the path resolves within the same repository.

For example, if the bootstrap package needs to depend on the "dependable" package, the "pubspec.yaml" of the bootstrap package might look like this:

name: 'plugin'
publish_to: 'none'

environment:
      sdk: '>=3.7.0-209.1.beta<3.7.0-209.2.beta'

dev_dependencies:
      dependable:
            git:
                  url: '../../../..' #<The relative path from this file's enclosing folder to the repository root.
                  path: 'pkg/dependable' #<The path from the repository root to the "dependable" package root.

@bwilkerson bwilkerson added area-devexp Developer Experience related issues (DevTools, IDEs, Analysis Server, completions, refactoring, etc) and removed area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-plugin area-devexp Developer Experience related issues (DevTools, IDEs, Analysis Server, completions, refactoring, etc) P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants