How to get a pub from GitHub as a dependency

I am studying Dart, but I found the problem:

I want to add the widget.dart package from my GitHub repository as a dependency for my project. But pub.dartlang.org has a very old version that requires an outdated web interface. Does anyone know how to get a pub from a GitHub repository (and install it like the one located at pub.dartlang.org)?

I use GitHub for Windows and the Dart Editor.


Update: I tried adding it to the dependency and running "pub get" in the classic way:

dependencies: widget: git: git@github.com :dart-lang/widget.dart.git 

But it returns this error:

 --- 30.1.2014 15:35:27 Running pub get ... --- Pub get failed, [1] Resolving dependencies... Cannot get widget from Git ( git@github.com :dart-lang/widget.dart.git). Please ensure Git is correctly installed. e:\b\build\slave\dart-editor-win-stable\build\dart\sdk\lib\_internal\pub\lib\src\source\git.dart 42 GitSource.downloadToSystemCache.<fn> dart:isolate _RawReceivePortImpl._handleMessage This is an unexpected error. Please run pub --trace 'get' and include the results in a bug report on http://dartbug.com/new. ** Warning: Application may fail to run since packages did not get installed.Try running pub get again. ** 
+6
source share
1 answer

Add the dependency to pubspec.yaml as

Edit pubspec.yaml in text mode

 dependencies: widget: git: git@github.com :dart-lang/widget.dart.git 

Using Assistant

if you open the pubspec.yaml file in DartEditor, you will get a nice helper

  • click Add...
  • Enter the package name: 'widget'
  • Change Source search from hosted to git
  • Set Git ref: to git@github.com :dart-lang/widget.dart.git

Additional Information:

  • You can find the dependency name in the pubspec.yaml file in the GitHub widget repository under name: widget
  • You can copy the git path from the GitHub repository in the SSH clone URL section (above the "Download ZIP" button).

EDIT
To do this, you need to install the git command line client on your local system.

You can download the repository manually

 git clone git@github.com :dart-lang/widget.dart.git 

and add the following dependency

 dependencies: widget: git: ../widget.dart # path: ../widget.dart # would work too 

Alternatively, you can download the repository from GitHub (Download as ZIP), extract it to your local drive and use the path: dependency, for example

 dependencies: widget: path: ../widget.dart 

provided that you have extracted the zip file to the sibling folder of your package.

See also https://www.dartlang.org/tools/pub/dependencies#git-packages

+8
source

All Articles