moonup
Manage multiple MoonBit installations
Getting Started
Install
Moonup is available for installation via different ways.
Conda (Cross-platform)
You can install moonup with conda/mamba/pixi from our conda-forge channel:
Cargo (Cross-platform, build from source)
If you have the Rust toolchain installed, you can install moonup easily with Cargo:
Homebrew (macOS)
If you are on macOS and you have Homebrew installed, you can install moonup from our Homebrew Tap:
Scoop (Windows)
If you are on Windows and you have Scoop installed:
scoop bucket add dorado https://github.com/chawyehsu/dorado
scoop install moonup
GitHub Releases
Or you may download the latest release from GitHub releases,
manually extract the archive and put the executables in a directory that is in your PATH.
Usage
After installation, run moonup help to see the available commands.
)
Install a MoonBit Toolchain
# install the latest MoonBit toolchain
# install the latest nightly MoonBit toolchain
# install a specific MoonBit toolchain (`v` prefix is not required)
Pin a MoonBit Toolchain
By pinning a MoonBit toolchain to a specific version in a project, the toolchain will be automatically switched to the pinned version when you're running MoonBit commands in the project directory. With this feature, you can ensure that the project is built and tested with the same MoonBit toolchain.
# remove the `moonbit-version` file to unpin
You're not required to install the pinned MoonBit toolchain in advance. Moonup will download and install the toolchain automatically when a command is run.
Set the Default Toolchain
The default toolchain is used when no toolchain is specified in a project. The
latest toolchain is used by default.
# change the default toolchain to the latest nightly
Check Installed and Active Toolchains
Run a Command with a Specific Toolchain
# or pass the version to the command directly! (syntax: `+<spec>`)
Uninstall a MoonBit Toolchain
# relevant cached downloads will be removed as well
# delete all cached downloads
Use Moonup in GitHub Actions
With the setup-moonup action, It's super easy to use Moonup to set up a MoonBit environment in GitHub CI. Here is an example workflow:
- name: Setup MoonBit
uses: chawyehsu/setup-moonup@v1
run: moon version --all
Distribution Server
Moonup is backed by chawyehsu/moonbit-binaries, a service built with GitHub Actions to continuously archive MoonBit releases from the official website and provide a distribution server with a stable API.
The default dist server endpoint is https://moonup.csu.moe/v2 at the
time of writing. Moonup supports overriding the distribution server with
the MOONUP_DIST_SERVER environment variable.
# set the distribution server to a custom endpoint
With this feature, you can configure Moonup to fetch and install MoonBit toolchains from a custom distribution server. This is useful when the default distribution server is not accessible in your environment, or when you want to host your own distribution server for MoonBit toolchains.
You have to build up the distribution server yourself though.
How It Works
Moonup allows you to install multiple MoonBit toolchains and switch between
them easily. All MoonBit toolchains (with the core standard library) are
installed in Moonup's toolchains directory.
Moonup creates shim executables that replace the original MoonBit executables in the PATH. When you run a MoonBit command, the shim executable determines which MoonBit toolchain to use and proxies the command to the actual MoonBit executable in the desired toolchain.
With this approach, you can switch between MoonBit toolchains across projects easily without needing to change the PATH.
Known Limitations
- Isolation of MoonBit core standard library is problematic, see #7.
Development
Prerequisites: Git, pixi
# clone the repo
# install dependencies
# install git prek(pre-commit) hooks
# dev build and run
# run tests
# enter dev environment shell
# dev tools available in the shell
0.1.0 Roadmap
- An
installcommand to install multiple MoonBit toolchains - A
pincommand to pin toolchain to a specific version in a project - Create shim executables to switch between toolchains automatically
- A
defaultcommand to set the default toolchain - A
showcommand to show installed and currently active toolchains - A
whichcommand to show the actual binary that will be run for a given command - A
runcommand to run a command with a specific toolchain - A
updatecommand to self-update and update the toolchain - A
completionscommand to generate shell completions
License
moonup © Chawye Hsu. Released under the Apache-2.0 license.
Blog · GitHub @chawyehsu · Twitter @chawyehsu