From 2bb7d8992ce7dfd80c5e9139a838344880c6c283 Mon Sep 17 00:00:00 2001 From: Zakaria Fatahi Date: Wed, 7 May 2025 17:22:51 +0200 Subject: [PATCH 1/3] Add Mise runtime version manager feature This commit introduces the Mise (formerly RTX) runtime version manager as a new devcontainer feature. Mise provides a unified tool to manage multiple language runtimes such as Node.js, Python, Ruby, and many others - Install Mise from official sources or specific version - Support for customizing which plugins to install - Compatible with Debian/Ubuntu, RHEL, and Alpine Linux - Automatic shell integration with bash and zsh - Full documentation and usage examples - Proper cleanup and error handling --- src/mise/NOTE.md | 24 +++++++++++ src/mise/devcontainer-feature.json | 41 ++++++++++++++++++ src/mise/install.sh | 67 ++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 src/mise/NOTE.md create mode 100644 src/mise/devcontainer-feature.json create mode 100644 src/mise/install.sh diff --git a/src/mise/NOTE.md b/src/mise/NOTE.md new file mode 100644 index 000000000..e5ca5e51e --- /dev/null +++ b/src/mise/NOTE.md @@ -0,0 +1,24 @@ +## Using Mise in your Dev Container + +After installing Mise, you can manage language versions by adding a `.mise.toml` file to your project root: + +```toml +[tools] +node = "20" +python = "3.11" +``` + +Or use the CLI to install tools: + +```bash +mise install node@20 +mise install python@3.11 +``` + +For more information on using Mise, see the [official documentation](https://mise.jdx.dev/). + +## OS Support + +This Feature should work on recent versions of Debian/Ubuntu, RedHat Enterprise Linux, Fedora, and Alpine Linux distributions with the `apt`, `yum` or `dnf` package manager installed. + +`bash` is required to execute the `install.sh` script. \ No newline at end of file diff --git a/src/mise/devcontainer-feature.json b/src/mise/devcontainer-feature.json new file mode 100644 index 000000000..225ec5718 --- /dev/null +++ b/src/mise/devcontainer-feature.json @@ -0,0 +1,41 @@ +{ + "id": "mise", + "version": "1.0.0", + "name": "Mise (formerly RTX)", + "documentationURL": "https://github.com/devcontainers/features/tree/main/src/mise", + "description": "Installs Mise, the unified runtime version manager (formerly RTX). Mise works like asdf, rvm, nvm, pyenv, etc - but is a single unified tool for managing all your runtimes.", + "options": { + "version": { + "type": "string", + "proposals": [ + "latest", + "none", + "v2025.5.0", + "v2025.4.12", + "v2025.4.11", + "v2025.4.10" + ], + "default": "latest", + "description": "Select or enter a Mise version to install" + }, + "installPlugins": { + "type": "string", + "default": "", + "description": "Comma separated list of Mise plugins to install (e.g., 'node,python,ruby')" + } + }, + "customizations": { + "vscode": { + "settings": { + "github.copilot.chat.codeGeneration.instructions": [ + { + "text": "This dev container includes Mise (formerly RTX), a unified runtime version manager pre-installed and available on the `PATH`. Mise allows you to manage multiple programming language versions (similar to asdf, nvm, pyenv, etc.) with a single tool." + } + ] + } + } + }, + "installsAfter": [ + "ghcr.io/devcontainers/features/common-utils" + ] +} \ No newline at end of file diff --git a/src/mise/install.sh b/src/mise/install.sh new file mode 100644 index 000000000..3d49e7453 --- /dev/null +++ b/src/mise/install.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- +# +# Docs: https://github.com/devcontainers/features/tree/main/src/mise +# Maintainer: The Dev Container spec maintainers + +set -eux + +# Feature options +MISE_VERSION="${VERSION}" +INSTALL_PLUGINS="${INSTALLPLUGINS:-""}" +UPDATE_RC="${UPDATE_RC:-"true"}" + +# Install dependencies based on OS +. /etc/os-release + +echo "(*) Installing dependencies for ${ID}..." +if [ "${ID}" = "debian" ] || [ "${ID}" = "ubuntu" ]; then + apt-get update + apt-get install -y curl ca-certificates +elif [ "${ID}" = "fedora" ] || [ "${ID}" = "rhel" ] || [ "${ID}" = "centos" ] || [ "${ID}" = "rocky" ] || [ "${ID}" = "almalinux" ]; then + if command -v dnf >/dev/null; then + dnf install -y curl + else + yum install -y curl + fi +fi + +# Install mise using the appropriate method for the OS +if [ "${MISE_VERSION}" != "none" ]; then + echo "(*) Installing mise version ${MISE_VERSION}..." + + export MISE_INSTALL_PATH="/usr/local/bin/mise" + if [ "${MISE_VERSION:-latest}" = "latest" ]; then + # latest: installer’s default, so don’t set MISE_VERSION + curl -sSf https://mise.run | sh + else + # pinned: pass through MISE_VERSION + curl -sSf https://mise.run | MISE_VERSION="${MISE_VERSION}" sh + fi + + # Verify mise is installed + if command -v mise >/dev/null 2>&1; then + echo "mise installed successfully: $(mise --version)" + else + echo "ERROR: mise installation failed. Could not find mise in PATH." + exit 1 + fi + + # Install plugins if specified + if [ -n "${INSTALL_PLUGINS}" ]; then + echo "Installing mise plugins: ${INSTALL_PLUGINS}" + IFS="," + read -ra plugins <<< "${INSTALL_PLUGINS}" + for plugin in "${plugins[@]}"; do + echo "Installing plugin: ${plugin}" + mise plugins install ${plugin} + done + fi +else + echo "Skipping mise installation as 'none' was specified." +fi + +echo "Done!" \ No newline at end of file From 8132ba04a1cf5ec1b4efe48a4c137769e66f5d7c Mon Sep 17 00:00:00 2001 From: Zakaria Fatahi Date: Wed, 7 May 2025 23:44:41 +0200 Subject: [PATCH 2/3] Add test scripts and scenarios for Mise feature across multiple distributions --- test/mise/debian.sh | 15 +++++++++++ test/mise/fedora.sh | 18 ++++++++++++++ test/mise/install_specific_version.sh | 12 +++++++++ test/mise/install_with_plugins.sh | 16 ++++++++++++ test/mise/rhel.sh | 17 +++++++++++++ test/mise/scenarios.json | 36 +++++++++++++++++++++++++++ test/mise/test.sh | 14 +++++++++++ 7 files changed, 128 insertions(+) create mode 100644 test/mise/debian.sh create mode 100644 test/mise/fedora.sh create mode 100644 test/mise/install_specific_version.sh create mode 100644 test/mise/install_with_plugins.sh create mode 100644 test/mise/rhel.sh create mode 100644 test/mise/scenarios.json create mode 100644 test/mise/test.sh diff --git a/test/mise/debian.sh b/test/mise/debian.sh new file mode 100644 index 000000000..0a142ed9d --- /dev/null +++ b/test/mise/debian.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "mise version" mise --version + +# Check for correct Debian paths +check "mise in PATH" bash -c "which mise | grep '/usr/local/bin/mise\\|/usr/bin/mise'" + +# Report result +reportResults \ No newline at end of file diff --git a/test/mise/fedora.sh b/test/mise/fedora.sh new file mode 100644 index 000000000..fc56ec1db --- /dev/null +++ b/test/mise/fedora.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "mise version" mise --version + +# Print out where mise actually lives +echo "DEBUG: mise resolved to: $(command -v mise)" + +# Check for correct Fedora paths +check "mise in PATH" bash -c "command -v mise | grep '/usr/local/bin/mise'" + +# Report result +reportResults \ No newline at end of file diff --git a/test/mise/install_specific_version.sh b/test/mise/install_specific_version.sh new file mode 100644 index 000000000..f233d555b --- /dev/null +++ b/test/mise/install_specific_version.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Check we have the expected version of mise +check "mise version v2024.5.17" bash -c "mise --version | grep '2024.5.17'" + +# Report result +reportResults \ No newline at end of file diff --git a/test/mise/install_with_plugins.sh b/test/mise/install_with_plugins.sh new file mode 100644 index 000000000..e15d37426 --- /dev/null +++ b/test/mise/install_with_plugins.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Check for mise +check "mise version" mise --version + +# Check for plugins +check "yarn plugin installed" bash -c "mise plugins list | grep yarn" +check "redis plugin installed" bash -c "mise plugins list | grep redis" + +# Report result +reportResults \ No newline at end of file diff --git a/test/mise/rhel.sh b/test/mise/rhel.sh new file mode 100644 index 000000000..0867c9c90 --- /dev/null +++ b/test/mise/rhel.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib +# Print out where mise actually lives +echo "DEBUG: mise resolved to: $(which mise)" + +# Definition specific tests +check "mise version" mise --version + +# Check for correct RHEL paths +check "mise in PATH" bash -c "command -v mise | grep '/usr/local/bin/mise'" + +# Report result +reportResults \ No newline at end of file diff --git a/test/mise/scenarios.json b/test/mise/scenarios.json new file mode 100644 index 000000000..a92e8bd4f --- /dev/null +++ b/test/mise/scenarios.json @@ -0,0 +1,36 @@ +{ + "install_specific_version": { + "image": "ubuntu:focal", + "features": { + "mise": { + "version": "v2024.5.17" + } + } + }, + "install_with_plugins": { + "image": "ubuntu:focal", + "features": { + "mise": { + "installPlugins": "yarn,redis" + } + } + }, + "rhel": { + "image": "almalinux:8", + "features": { + "mise": {} + } + }, + "debian": { + "image": "debian:bullseye", + "features": { + "mise": {} + } + }, + "fedora": { + "image": "fedora:latest", + "features": { + "mise": {} + } + } +} \ No newline at end of file diff --git a/test/mise/test.sh b/test/mise/test.sh new file mode 100644 index 000000000..ab9ed51f0 --- /dev/null +++ b/test/mise/test.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "mise version" mise --version +check "mise activate command" mise activate bash +check "mise plugins command" mise plugins list + +# Report result +reportResults \ No newline at end of file From 057628ba6d86067fa8136a28355aa2c59d1766f9 Mon Sep 17 00:00:00 2001 From: Zakaria Fatahi Date: Wed, 7 May 2025 23:53:07 +0200 Subject: [PATCH 3/3] Remove unused UPDATE_RC variable from install script --- src/mise/install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mise/install.sh b/src/mise/install.sh index 3d49e7453..0438512fb 100644 --- a/src/mise/install.sh +++ b/src/mise/install.sh @@ -12,7 +12,6 @@ set -eux # Feature options MISE_VERSION="${VERSION}" INSTALL_PLUGINS="${INSTALLPLUGINS:-""}" -UPDATE_RC="${UPDATE_RC:-"true"}" # Install dependencies based on OS . /etc/os-release