Pre Dart 2.12
Last updated
Was this helpful?
Last updated
Was this helpful?
If you are running an older version of Dart (prior to 2.12) then you need to use one of these alternate installation methods which involve either compiling or downloading the onepub and opub executables.
download the OnePub commands
use opub xxx
in place of dart/flutter pub xxx
With the release of Dart 2.15 Google introduced support for private package repositories such as OnePub. Older versions of Dart are unable to authenticate against a private package repository.
To get around this problem, OnePub includes a back ported version of the full dart/flutter pub
command as the opub
CLI command.
This allows you to substitute any flutter pub
or dart pub
command with opub
.
Use opub xxx
in place of dart pub xxx
or flutter pub xxx
The problem for users of pre 2.12 versions of Dart is that the opub command requires dart 2.12 (the code is null safe). This means you can't globally activate the opub command on systems running older versions of Dart.
To solve this problem you can either compile your own version of OnePub or download our pre-compiled versions.
Downloading the executables is the easiest path forward but if you don't want to trust a third party executable we also provide instructions on compiling the code from source.
For pre dart 2.12 users download the pre-compiled OnePub command line tools.
onepub
opub
After downloading each exe run:
Download both onepub and opub and add them to your system PATH.
Now use opub anywhere you would normally use dart pub...
or flutter pub...
For either of the alternate compile techniques you must be running at least version 2.12 of Dart.
Once you have compiled the two executables you can copy the to your local system and revert your Dart version.
from .pub-cache
Start by ensuring you are running at least Dart 2.12.
dart --version
DCli, known as the Console SDK for Dart
, allows you to compile a Dart CLI package directly from your local .pub-cache adding the resulting executables to your path.
Start by installing DCli
The install step provides instructions to add the ~/.dcli/bin path to your PATH. Make certain you complete this step. You may need to restart your terminal (or even logout) to see the PATH changes.
Now we can install and compile OnePub.
The above compile command will compile both of the onepub executables (onepub and opub).
We have now compiled two executables, onepub and opub which have been copied to the ~/.dcli/bin directory which should be on your PATH.
You can now revert to your preferred version of Dart.
Start by ensuring you are running at least Dart 2.12.
dart --version
If you want to use all dart native tooling then you can compile OnePub by cloning the OnePub git repo.
To compile the OnePub commands run:
Now copy the resulting exectuables (located in the bin directory) to a directory on your local system's PATH.
The onepub
and opub
commands will now run regardless of which version of Dart is active.
You can now revert to your preferred version of Dart.
You can either do this on a separate machine (or a VM), temporarily install a more recent version of Dart or use which supports as far back as Dart 2.5. If you are not familiar with fvm (flutter version manager) it allows you to rapidly switch between different versions of flutter.
You can compile your own version of OnePub using a couple of techniques. The simplest is to compile from .pub-cache using .