LogoLogo
  • OnePub
  • Guides
    • Installing
      • Install CLI tools
      • Register
      • Invite a member
      • Accept an Invite
      • CLI integration
        • Manually add publish_to
        • Implicit Integration
      • IDE integration
        • Android Studio
        • Visual Studio Code
      • Pre Dart 2.15
      • Pre Dart 2.12
    • Searching
    • Watching packages
    • Publishing Packages
      • The hard way
    • Private dependencies
      • The hard way
    • CLI Tools
      • login
      • logout
      • doctor
      • export
      • import
      • pub add
      • pub private
      • pub global activate
      • pub global deactivate
    • CI/CD
    • SSH
    • Docker
    • Community Choice Awards
  • Fundamentals
    • Members
    • Teams
    • Roles
    • Naming Packages
  • Workflows
    • Distributing to Customers
      • Purchase a Customer Distribution License
      • Security considerations
      • Publish a package
      • Invite a customer
      • Customer installation instructions
      • Conditions Apply
    • For Support
    • Setting up CI/CD
    • Vendoring Dependencies
    • Switching Organisations
    • Creating a Team Leader
  • FAQ
    • Is GST/VAT/Sales Tax applicable?
    • Does OnePub.dev have access to my personal information?
    • What is your SLA?
    • How do I get support?
    • How do I use OnePub from my CI/CD environment?
    • How to invite team members to join OnePub
    • How to publish a private package
    • 401: Unauthorized
  • Solved by OnePub
  • Data Retention Policy
  • Payments
Powered by GitBook
On this page
  • Download
  • Compiling
  • Compile from .pub-cache
  • Compile from git

Was this helpful?

  1. Guides
  2. Installing

Pre Dart 2.12

PreviousPre Dart 2.15NextSearching

Last updated 2 years ago

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

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.

Download

For pre dart 2.12 users download the pre-compiled OnePub command line tools.

onepub

wget https://github.com/onepub-dev/onepub/releases/download/Linux%2Flatest/onepub

opub

wget https://github.com/onepub-dev/onepub/releases/download/Linux%2Flatest/opub

After downloading each exe run:

chmod +x onepub
chmod +x opub

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...

Compiling

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.

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.

To compile the OnePub commands run:

git clone https://github.com/onepub-dev/onepub
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.

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 .

fvm
DCli
Windows latest release of onepub
Windows latest release of opub
MacOS latest release of onepub
MacOS latest release of opub
pre-compiled
GitHub - onepub-dev/onepub: Cli tooling and support for OnePub the private package repository for Dart and FlutterGitHub
Clone the OnePub repo
Logo