Code Monkey home page Code Monkey logo

asdf-dart's Introduction

asdf-dart

dart plugin for asdf version manager

Requirements

  • curl
  • unzip or 7z to decompress the downloaded zip

Install

asdf plugin add dart https://github.com/patoconnor43/asdf-dart.git

Use

Check the asdf instructions for how to install and set your Dart version.

Customization

The default behavior for this plugin used to include dev and beta versions when listing all the versions. This got really noisy and interfered with asdf install dart latest installing the latest stable version. If you want to re-enable these channels you can set these environment variables.

ASDF_DART_ENABLE_BETA=true
ASDF_DART_ENABLE_DEV=true

These environment variables will ensure only the base versions are included.

Installation differences between Dart 1 and Dart 2

All Dart 1 versions come with corresponding versions of content_shell and dartium. Since Dart 2 doesn't use these tools, they aren't included. For more information on tooling differences, check out the docs.

Using in your favorite IDE/Editor

Dart plugins for IntelliJ, VS Code, etc., typically need you to provide a path where the Dart SDK is installed. Using asdf installs Dart in a consistent place, but may be confusing if you don't know where that is. The install location can be found by running asdf where dart, which should be $HOME/.asdf/installs/dart/VERSION Continuously updating this path can get annoying between upgrades or if you're doing work between Dart 1 and 2. Because of this I added a script to this repo (tools/dart_version_watcher.sh) that will create a file watcher for any time your global versions change and then update a symlink that points to the current version. This means you can point your IDE at ${HOME}/.asdf_dart_sdk and anytime you change versions, this file will point to the most recent version. If you're interested check the install instructions inside the tools/ directory.

Included Shims

  • dart2js
  • dart2native
  • dart
  • dartanalyzer
  • dartaotruntime
  • dartdevc
  • dartdevc
  • dartdoc
  • dartfmt
  • pub
  • and many more...
  • content_shell (Dart 1 exclusive)
  • dartium (Dart 1 exclusive)

Working with multiple SDKs

If you're using this plugin it's probably because you're using multiple versions of the Dart SDK. This means you also want to be able to use different versions of the language server. This is easy enough in Vim/Neovim by getting the language server path by running asdf where dart. In VSCode, you'll probably want to use the dart.sdkPaths setting. This will allow you to add a path where your SDKs are located and then switch them on the fly. An example value for this setting is <an absolute path to your asdf folder>/installs/dart. If you hover over the Dart Syntax Switcher in the bottom right of the editor you should see a way to change which SDK you want to use.

A screenshot showing a popup menu when hovering over the
syntax selector in VSCode. There is a label that shows the current Dart version
and a button that says 'change'.

IMPORTANT NOTE: If there are versions of the SDK that are installed, but don't show up in the menu, you should be able to uninstall and re-install those versions. This is due to a path change that was necessary to facilitate this feature.

Shoutout to @Rapougnac for bringing this up!

Contributing

Feel free to create an issue or pull request if you find a bug.

License

MIT License

asdf-dart's People

Contributors

jayjah avatar kimlarson-wk avatar lauracallahan-wk avatar patoconnor43 avatar r3jack avatar rapougnac avatar yuriy-yarosh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

asdf-dart's Issues

Path to dart sdk in readme

I had to use $HOME/.asdf/installs/dart/2.13.4/dart-sdk, though the readme says $HOME/.asdf/installs/dart/VERSION. Confused me (and intellij) for a bit :)

Protect against attempting to download invalid versions

Problem

The install script should validate the requested version before trying to download. This can result in empty downloads.

Proposed Solution

Either abort the install process if the user requests a version that is not included in the list-all script or allow supporting truncated versions (2 vs. 2.3.2) that will install the newest version version that starts with that major.

Reported in #5

Apple Silicon M1 should download corresponding Dart Sdk

When you're on an Apple Silicon M1, it should download the correct Dart SDK, which is the ARM64 architecture version.
Currently this cpu architecture is silently ignored and so it downloads the x64 architecture.

See here:

get_arch () {
    local arch=""

    case "$(uname -m)" in
        x86_64|amd64|arm64) arch="x64"; ;;
        i686|i386) arch="ia32"; ;;
        *)
            echo "Arch '$(uname -m)' not supported!" >&2
            ;;
    esac

    echo -n $arch
}

Support M1 macs architecture

Current behavior defaults to downloading x64. In the case of 2.14+ versions, there is an arm64 version for M1 darwin.

Modify the architecture check to point to arm64 if available. I believe it will require a change here

# on an M1
$> uname -m
arm64

does not install properly

For some reason installs are failing for dart 1 and 2.

asdf install dart 2
Platform 'darwin' supported!
version
2
/Users/masha/.asdf/installs/dart/2
macos
x64
asdf-dart.xgsQ
0
2
Installing Dart SDK...
https://storage.googleapis.com/dart-archive/channels/stable/release/2/sdk/dartsdk-macos-x64-release.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   234  100   234    0     0   1800      0 --:--:-- --:--:-- --:--:--  1800
Unzipping Dart SDK to /Users/masha/.asdf/installs/dart/2...

The zip file downloaded is invalid

Not working for some reason

When everything seems to work fine at first, but it seems as though the package is never actually extracted

Platform 'linux' supported!
Version: 2.8.4
Install Path: /home/watzon/.asdf/installs/dart/2.8.4
Platform: linux
Architecture: x64
Downloading to temp directory asdf-dart.HjnW
Include Extras: 0
Major Dart Version: 2
Installing Dart SDK...
https://storage.googleapis.com/dart-archive/channels/stable/release/2.8.4/sdk/dartsdk-linux-x64-release.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  217M  100  217M    0     0  54.8M      0  0:00:03  0:00:03 --:--:-- 54.8M
Unzipping Dart SDK to /home/watzon/.asdf/installs/dart/2.8.4...

Running on Arch

`asdf install dart latest` no longer downloads the latest version of Dart

The current latest version of Dart is 2.10.4, but asdf latest dart returns 2.9.3. Looking at the URL you use to get available versions, it quickly becomes obvious why your method has stopped working:

...
"channels/stable/release/2.9.1/",
"channels/stable/release/2.9.2/",
"channels/stable/release/2.9.3/",
"channels/stable/release/29803/",
"channels/stable/release/30036/",
"channels/stable/release/30107/",
...

Luckily asdf install dart 2.10.4 still works just fine.

asdf latest dart should return the latest stable version

The documentation and CLI help describe asdf latest <name> as the command that should "Show Latest Stable Version", but currently for dart it does not filter out beta/dev channel releases so you get something like 2.13.0-114.0.dev. I saw in another issue thread that there is an option to filtering out beta/dev, but the asdf docs make it sound like that should be the default behavior for asdf latest.

By the way, this is awesome - thank you @PatOConnor43!

Plans supporting beta/dev channnel

First of all, thank you for creating such a nice plugin. I use almost everyday ❤️

Currently, asdf-dart supports only stable channel.
I would appreciate it if you also supports beta and dev channel too.

Do you have any plans to implement it?

mktemp alpine fix

Busybox mktemp has different command line args, as per getssl/#612.

Which leads to writing sdk.zip into the root dir

bash -c 'source .bashrc && asdf install dart 2.19.6'
1.689 Platform 'linux' supported!
1.690 mktemp: Invalid argument
1.691 Version: 2.19.6
1.691 Install Path: /builder/.asdf/installs/dart/2.19.6
1.691 Platform: linux
1.691 Architecture: x64
1.691 Downloading to temp directory
1.691 Include Extras: 0
1.691 Major Dart Version: 2
1.691 Installing Dart SDK...
1.691 https://storage.googleapis.com/dart-archive/channels/stable/release/2.19.6/sdk/dartsdk-linux-x64-release.zip
1.693   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
1.693                                  Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Failed to open the file /sdk.zip: Permission denied
  0  207M    0  5503    0     0  22611      0  2:40:41 --:--:--  2:40:41 22646
1.936 curl: (23) Failure writing output to destination

Adding version watcher script to .zshrc causes VS Code shell environment to time out

I have the following line at the bottom of my .zshrc file:

bash ${HOME}/.asdf/plugins/dart/tools/dart_version_watcher.sh

I didn't notice a problem for a while (due to my penchant to not close VS Code windows very often), but when starting up VS Code after a computer reboot, the shell environment took a while to initialize, after which I got a message saying "Unable to resolve your shell environment in a reasonable time. Please review your shell configuration." After that point, the integrated terminal was frozen on "Starting" no matter what I did. After some investigation, I narrowed the cause down to the above command.

Note that this only happens when VS Code is first starting up. If I comment that line and start up VS Code, then uncomment the line and refresh the integrated terminal with the zsh command, the terminal successfully refreshes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.