I wanted to experiment with Dart. I had installed Flutter and the Dart installation instructions said that if you had Flutter installed, you don’t need to install Dart separately.
My computer couldn’t find the dart
command though:
$ dart
zsh: command not found: dart
Running flutter doctor -v
showed that Dart is installed:
$ flutter doctor -v
[✓] Flutter (Channel beta, 1.20.0-7.3.pre, on Linux, locale en_US.UTF-8)
• Flutter version 1.20.0-7.3.pre at /home/username/snap/flutter/common/flutter
• Framework revision e606910f28 (33 hours ago), 2020-07-28 16:06:37 -0700
• Engine revision ac95267aef
• Dart version 2.9.0 (build 2.9.0-21.10.beta)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at /home/username/Android/Sdk
• Platform android-30, build-tools 30.0.1
• Java binary at: /home/username/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• CHROME_EXECUTABLE = /usr/bin/chromium-browser
[✓] Android Studio (version 4.0)
• Android Studio at /home/username/android-studio
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] Connected device (2 available)
• Web Server (web) • web-server • web-javascript • Flutter Tools
• Chrome (web) • chrome • web-javascript • Chromium 84.0.4147.89 snap
• No issues found!
Eventually, I found it ~/snap/flutter/common/flutter/bin
:
$ ~/snap/flutter/common/flutter/bin/dart --version
Dart SDK version: 2.9.0-21.10.beta (beta) (Tue Jul 21 10:46:30 2020 +0200) on "linux_x64"
To fix it, I added a symlink to my ~/bin
directory which is on my path:
$ cd ~/bin
$ ln -s ~/snap/flutter/common/flutter/bin/dart .
Now it works:
$ dart --version
Dart SDK version: 2.9.0-21.10.beta (beta) (Tue Jul 21 10:46:30 2020 +0200) on "linux_x64"
I’m posting this here, because I couldn’t find an answer online, so maybe someone will find this page in a search engine.
Edit: to find the pub
command:
$ ~/flutter/bin/cache/dart-sdk/bin/pub --version
I fixed it the same way:
$ cd ~/bin
$ ln -s ~/flutter/bin/cache/dart-sdk/bin/pub .
After that I was able to download stagehand:
$ pub global activate stagehand
Be sure to read the output from that command, because it has instructions for putting stagehand
on the path:
Warning: Pub installs executables into $HOME/.pub-cache/bin, which is not on your path.
You can fix that by adding this to your shell's config file (.bashrc, .bash_profile, etc.):
export PATH="$PATH":"$HOME/.pub-cache/bin"
Edit 2: dart2native
is in ~/snap/flutter/common/flutter/bin/cache/dart-sdk/bin/dart2native
I don’t know if everything works yet, but that might help people get at least part of the way there. Leave a comment below if you know a better method.