Chris G.
Chris G.

Reputation: 25924

Use pub global activate --source path from other local dart project

I am trying this, and it works great for terminal applications to reference $HOME/.pub-cache/bin

Can I use an activated local package from other local projects?

Steps:
1. pub global activate --source path . From package project
2. Then how to use this in another project pubspec.yaml dependencies: section?

I know I can use path, but this is much better for dynamic reference reasons.

If I add this in pubspect.yaml dependencies in the project using cli2 package:

dependencies:
  cli2: 0.0.0 # name of: pub global activate --source path .

I get this error:

Because usecli2 depends on cli2 any which doesn't exist (could not find package cli2 at https://pub.dartlang.org), version solving failed.

Upvotes: 3

Views: 1300

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657018

pub global activate is to install Dart scripts from bin/ of a package as command line executables and is completely unrelated to adding dependencies to a project.

You can use relative paths to add local dependencies:

dependencies:
  cli2
    path: ../cli2

Upvotes: 1

Related Questions