Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

dart

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.
like image 845
Chris G. Avatar asked Jan 29 '26 08:01

Chris G.


1 Answers

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
like image 151
Günter Zöchbauer Avatar answered Feb 01 '26 15:02

Günter Zöchbauer