Pre Dart 2.12

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 pre-compiled OnePub commands

  • use opub xxx in place of dart/flutter pub xxx

If you are hesitating about upgrading your Dart version because of Null Safety then don't be. It's a fairly painless process with google's migration tools doing most of the heavy lifting. You will reap the benefits almost immediately, often finding and fixing bugs as part of the migration.

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.





After downloading each exe run:

chmod +x onepub
chmod +x opub

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.

You can either do this on a separate machine (or a VM), temporarily install a more recent version of Dart or use fvm 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.

Once you have compiled the two executables you can copy the to your local system and revert your Dart version.

You can compile your own version of OnePub using a couple of techniques. The simplest is to compile from .pub-cache using DCli.

Compile 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

dart pub global activate dcli
dcli install

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.

dart pub global activate onepub
dcli compile --package 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.

Compile from git

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.

Clone the OnePub repo

To compile the OnePub commands run:

git clone
cd onepub
dart pub get
dart compile exe bin/onepub.dart -o bin/onepub
dart compile exe bin/opub.dart -o bin/onepub

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.

Last updated