Parity with the node feature
This commit is contained in:
parent
d53b9d1816
commit
e84b5526bc
8 changed files with 90 additions and 108 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "ruby",
|
"id": "ruby",
|
||||||
"version": "1.2.0",
|
"version": "1.2.0", // TODO - Is this a major or a minor update? Major, probably.
|
||||||
"name": "Ruby (via rvm)",
|
"name": "Ruby",
|
||||||
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/ruby",
|
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/ruby",
|
||||||
"description": "Installs Ruby, rvm, rbenv, common Ruby utilities, and needed dependencies.",
|
"description": "Installs Ruby, rvm, rbenv, common Ruby utilities, and needed dependencies.",
|
||||||
"options": {
|
"options": {
|
||||||
|
@ -9,13 +9,19 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"proposals": [
|
"proposals": [
|
||||||
"latest",
|
"latest",
|
||||||
|
"os-provided",
|
||||||
"none",
|
"none",
|
||||||
|
"3.2",
|
||||||
"3.1",
|
"3.1",
|
||||||
"3.0",
|
"3.0"
|
||||||
"2.7"
|
|
||||||
],
|
],
|
||||||
"default": "latest",
|
"default": "latest",
|
||||||
"description": "Select or enter a Ruby version to install"
|
"description": "Select or enter a Ruby version to install"
|
||||||
|
},
|
||||||
|
"additionalVersions": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "",
|
||||||
|
"description": "Enter additional versions, separated by commas."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"customizations": {
|
"customizations": {
|
||||||
|
|
|
@ -7,26 +7,22 @@
|
||||||
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/ruby.md
|
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/ruby.md
|
||||||
# Maintainer: The VS Code and Codespaces Teams
|
# Maintainer: The VS Code and Codespaces Teams
|
||||||
|
|
||||||
RUBY_VERSION="${VERSION:-"latest"}"
|
export RUBY_VERSION="${VERSION:-"latest"}"
|
||||||
|
|
||||||
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
|
|
||||||
UPDATE_RC="${UPDATE_RC:-"true"}"
|
|
||||||
INSTALL_RUBY_TOOLS="${INSTALL_RUBY_TOOLS:-"true"}"
|
INSTALL_RUBY_TOOLS="${INSTALL_RUBY_TOOLS:-"true"}"
|
||||||
|
|
||||||
# Comma-separated list of ruby versions to be installed (with rvm)
|
# Comma-separated list of ruby versions to be installed (with rvm)
|
||||||
# alongside RUBY_VERSION, but not set as default.
|
# alongside RUBY_VERSION, but not set as default.
|
||||||
ADDITIONAL_VERSIONS="${ADDITIONALVERSIONS:-""}"
|
ADDITIONAL_VERSIONS="${ADDITIONALVERSIONS:-""}"
|
||||||
|
|
||||||
# Note: ruby-debug-ide will install the right version of debase if missing and
|
GPG_KEY_SERVERS="keyserver hkps://keys.openpgp.org
|
||||||
# installing debase directly fails on Ruby 3.1.0 as of 1/7/2022, so omitting.
|
keyserver hkp://keyserver.pgp.com
|
||||||
# installing ruby-debug-ide on debian fails, so omitting.
|
keyserver hkp://pgp.mit.edu
|
||||||
DEFAULT_GEMS="rake"
|
keyserver hkp://ipv4.pool.sks-keyservers.net
|
||||||
|
keyserver hkp://keyserver.ubuntu.com
|
||||||
|
keyserver hkp://keyserver.ubuntu.com:80"
|
||||||
|
|
||||||
RVM_GPG_KEYS="409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB"
|
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
|
||||||
GPG_KEY_SERVERS="keyserver hkp://keyserver.ubuntu.com
|
UPDATE_RC="${UPDATE_RC:-"true"}"
|
||||||
keyserver hkp://keyserver.ubuntu.com:80
|
|
||||||
keyserver hkps://keys.openpgp.org
|
|
||||||
keyserver hkp://keyserver.pgp.com"
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
@ -106,7 +102,7 @@ receive_gpg_keys() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Figure out correct version of a three part version number is not passed
|
# Figure out correct version if a three part version number is not passed
|
||||||
find_version_from_git_tags() {
|
find_version_from_git_tags() {
|
||||||
local variable_name=$1
|
local variable_name=$1
|
||||||
local requested_version=${!variable_name}
|
local requested_version=${!variable_name}
|
||||||
|
@ -169,11 +165,11 @@ fi
|
||||||
check_packages curl ca-certificates software-properties-common build-essential gnupg2 libreadline-dev \
|
check_packages curl ca-certificates software-properties-common build-essential gnupg2 libreadline-dev \
|
||||||
procps dirmngr gawk autoconf automake bison libffi-dev libgdbm-dev libncurses5-dev \
|
procps dirmngr gawk autoconf automake bison libffi-dev libgdbm-dev libncurses5-dev \
|
||||||
libsqlite3-dev libtool libyaml-dev pkg-config sqlite3 zlib1g-dev libgmp-dev libssl-dev
|
libsqlite3-dev libtool libyaml-dev pkg-config sqlite3 zlib1g-dev libgmp-dev libssl-dev
|
||||||
|
|
||||||
if ! type git > /dev/null 2>&1; then
|
if ! type git > /dev/null 2>&1; then
|
||||||
check_packages git
|
check_packages git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Figure out correct version of a three part version number is not passed
|
# Figure out correct version of a three part version number is not passed
|
||||||
find_version_from_git_tags RUBY_VERSION "https://github.com/ruby/ruby" "tags/v" "_"
|
find_version_from_git_tags RUBY_VERSION "https://github.com/ruby/ruby" "tags/v" "_"
|
||||||
|
|
||||||
|
@ -181,21 +177,20 @@ find_version_from_git_tags RUBY_VERSION "https://github.com/ruby/ruby" "tags/v"
|
||||||
if rvm --version > /dev/null; then
|
if rvm --version > /dev/null; then
|
||||||
echo "Ruby Version Manager already exists."
|
echo "Ruby Version Manager already exists."
|
||||||
if [[ "$(ruby -v)" = *"${RUBY_VERSION}"* ]]; then
|
if [[ "$(ruby -v)" = *"${RUBY_VERSION}"* ]]; then
|
||||||
echo "(!) Ruby is already installed with version ${RUBY_VERSION}. Skipping..."
|
echo "(!) Ruby is already installed with version ${RUBY_VERSION}."
|
||||||
elif [ "${RUBY_VERSION}" != "none" ]; then
|
elif [ "${RUBY_VERSION}" != "none" ]; then
|
||||||
echo "Installing specified Ruby version."
|
echo "Installing specified Ruby version."
|
||||||
su ${USERNAME} -c "rvm install ruby ${RUBY_VERSION}"
|
su ${USERNAME} -c "rvm install ruby ${RUBY_VERSION}"
|
||||||
fi
|
fi
|
||||||
SKIP_GEM_INSTALL="false"
|
|
||||||
SKIP_RBENV_RBUILD="true"
|
|
||||||
else
|
else
|
||||||
# Install RVM
|
# Install RVM
|
||||||
|
RVM_GPG_KEYS="409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB"
|
||||||
receive_gpg_keys RVM_GPG_KEYS
|
receive_gpg_keys RVM_GPG_KEYS
|
||||||
# Determine appropriate settings for rvm installer
|
# Determine appropriate settings for rvm installer
|
||||||
if [ "${RUBY_VERSION}" = "none" ]; then
|
if [ "${RUBY_VERSION}" = "none" ]; then
|
||||||
RVM_INSTALL_ARGS=""
|
RVM_INSTALL_ARGS=""
|
||||||
elif [[ "$(ruby -v)" = *"${RUBY_VERSION}"* ]]; then
|
elif [[ "$(ruby -v)" = *"${RUBY_VERSION}"* ]]; then
|
||||||
echo "(!) Ruby is already installed with version ${RUBY_VERSION}. Skipping..."
|
echo "(!) Ruby is already installed with version ${RUBY_VERSION}."
|
||||||
RVM_INSTALL_ARGS=""
|
RVM_INSTALL_ARGS=""
|
||||||
else
|
else
|
||||||
if [ "${RUBY_VERSION}" = "latest" ] || [ "${RUBY_VERSION}" = "current" ] || [ "${RUBY_VERSION}" = "lts" ]; then
|
if [ "${RUBY_VERSION}" = "latest" ] || [ "${RUBY_VERSION}" = "current" ] || [ "${RUBY_VERSION}" = "lts" ]; then
|
||||||
|
@ -204,31 +199,19 @@ else
|
||||||
else
|
else
|
||||||
RVM_INSTALL_ARGS="--ruby=${RUBY_VERSION}"
|
RVM_INSTALL_ARGS="--ruby=${RUBY_VERSION}"
|
||||||
fi
|
fi
|
||||||
if [ "${INSTALL_RUBY_TOOLS}" = "true" ]; then
|
|
||||||
SKIP_GEM_INSTALL="true"
|
|
||||||
else
|
|
||||||
DEFAULT_GEMS=""
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
# Create rvm group as a system group to reduce the odds of conflict with local user UIDs
|
# Create rvm group as a system group to reduce the odds of conflict with local user UIDs
|
||||||
if ! cat /etc/group | grep -e "^rvm:" > /dev/null 2>&1; then
|
if ! cat /etc/group | grep -e "^rvm:" > /dev/null 2>&1; then
|
||||||
groupadd -r rvm
|
groupadd -r rvm
|
||||||
fi
|
fi
|
||||||
# Install rvm
|
# Install rvm
|
||||||
curl -sSL https://get.rvm.io | bash -s stable --ignore-dotfiles ${RVM_INSTALL_ARGS} --with-default-gems="${DEFAULT_GEMS}" 2>&1
|
curl -sSL https://get.rvm.io | bash -s stable --ignore-dotfiles ${RVM_INSTALL_ARGS} 2>&1
|
||||||
usermod -aG rvm ${USERNAME}
|
usermod -aG rvm ${USERNAME}
|
||||||
source /usr/local/rvm/scripts/rvm
|
source /usr/local/rvm/scripts/rvm
|
||||||
rvm fix-permissions system
|
rvm fix-permissions system
|
||||||
rm -rf ${GNUPGHOME}
|
rm -rf ${GNUPGHOME}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${INSTALL_RUBY_TOOLS}" = "true" ]; then
|
|
||||||
# Non-root user may not have "gem" in path when script is run and no ruby version
|
|
||||||
# is installed by rvm, so handle this by using root's default gem in this case
|
|
||||||
ROOT_GEM="$(which gem || echo "")"
|
|
||||||
${ROOT_GEM} install ${DEFAULT_GEMS}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# VS Code server usually first in the path, so silence annoying rvm warning (that does not apply) and then source it
|
# VS Code server usually first in the path, so silence annoying rvm warning (that does not apply) and then source it
|
||||||
updaterc "if ! grep rvm_silence_path_mismatch_check_flag \$HOME/.rvmrc > /dev/null 2>&1; then echo 'rvm_silence_path_mismatch_check_flag=1' >> \$HOME/.rvmrc; fi\nsource /usr/local/rvm/scripts/rvm > /dev/null 2>&1"
|
updaterc "if ! grep rvm_silence_path_mismatch_check_flag \$HOME/.rvmrc > /dev/null 2>&1; then echo 'rvm_silence_path_mismatch_check_flag=1' >> \$HOME/.rvmrc; fi\nsource /usr/local/rvm/scripts/rvm > /dev/null 2>&1"
|
||||||
|
|
||||||
|
@ -246,59 +229,12 @@ if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
|
||||||
IFS=$OLDIFS
|
IFS=$OLDIFS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install rbenv/ruby-build for good measure
|
|
||||||
if [ "${SKIP_RBENV_RBUILD}" != "true" ]; then
|
|
||||||
|
|
||||||
if [[ ! -d "/usr/local/share/rbenv" ]]; then
|
|
||||||
git clone --depth=1 \
|
|
||||||
-c core.eol=lf \
|
|
||||||
-c core.autocrlf=false \
|
|
||||||
-c fsck.zeroPaddedFilemode=ignore \
|
|
||||||
-c fetch.fsck.zeroPaddedFilemode=ignore \
|
|
||||||
-c receive.fsck.zeroPaddedFilemode=ignore \
|
|
||||||
https://github.com/rbenv/rbenv.git /usr/local/share/rbenv
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -d "/usr/local/share/ruby-build" ]]; then
|
|
||||||
git clone --depth=1 \
|
|
||||||
-c core.eol=lf \
|
|
||||||
-c core.autocrlf=false \
|
|
||||||
-c fsck.zeroPaddedFilemode=ignore \
|
|
||||||
-c fetch.fsck.zeroPaddedFilemode=ignore \
|
|
||||||
-c receive.fsck.zeroPaddedFilemode=ignore \
|
|
||||||
https://github.com/rbenv/ruby-build.git /usr/local/share/ruby-build
|
|
||||||
mkdir -p /root/.rbenv/plugins
|
|
||||||
|
|
||||||
ln -s /usr/local/share/ruby-build /root/.rbenv/plugins/ruby-build
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${USERNAME}" != "root" ]; then
|
|
||||||
mkdir -p /home/${USERNAME}/.rbenv/plugins
|
|
||||||
|
|
||||||
if [[ ! -d "/home/${USERNAME}/.rbenv/plugins/ruby-build" ]]; then
|
|
||||||
ln -s /usr/local/share/ruby-build /home/${USERNAME}/.rbenv/plugins/ruby-build
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Oryx expects ruby to be installed in this specific path, else it breaks the oryx magic for ruby projects.
|
|
||||||
if [ ! -f /usr/local/rvm/gems/default/bin/ruby ]; then
|
|
||||||
ln -s /usr/local/rvm/rubies/default/bin/ruby /usr/local/rvm/gems/default/bin
|
|
||||||
fi
|
|
||||||
|
|
||||||
chown -R "${USERNAME}:rvm" "/home/${USERNAME}/.rbenv/"
|
|
||||||
chmod -R g+r+w "/home/${USERNAME}/.rbenv"
|
|
||||||
find "/home/${USERNAME}/.rbenv" -type d | xargs -n 1 chmod g+s
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
chown -R "${USERNAME}:rvm" "/usr/local/rvm/"
|
chown -R "${USERNAME}:rvm" "/usr/local/rvm/"
|
||||||
chmod -R g+r+w "/usr/local/rvm/"
|
chmod -R g+r+w "/usr/local/rvm/"
|
||||||
find "/usr/local/rvm/" -type d | xargs -n 1 chmod g+s
|
find "/usr/local/rvm/" -type d | xargs -n 1 chmod g+s
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
rvm cleanup all
|
rvm cleanup all
|
||||||
${ROOT_GEM} cleanup
|
|
||||||
|
|
||||||
# Clean up
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
echo "Done!"
|
echo "Done!"
|
||||||
|
|
12
test/ruby/additional_versions.sh
Normal file
12
test/ruby/additional_versions.sh
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Optional: Import test library
|
||||||
|
source dev-container-features-test-lib
|
||||||
|
|
||||||
|
check "3.0.6 installed" bash -c "rvm list | fgrep 3.0.6"
|
||||||
|
check "2.7.8 installed" bash -c "rvm list | fgrep 2.7.8"
|
||||||
|
|
||||||
|
# Report result
|
||||||
|
reportResults
|
|
@ -1,16 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Optional: Import test library
|
|
||||||
source dev-container-features-test-lib
|
|
||||||
|
|
||||||
check "ruby version 3.1.2 installed as default" ruby -v | grep 3.1.2
|
|
||||||
check "ruby version 2.5.9 installed" rvm list | grep 2.5.9
|
|
||||||
check "ruby version 3.0.4 installed" rvm list | grep 3.0.4
|
|
||||||
|
|
||||||
check "rbenv" bash -c 'eval "$(rbenv init -)" && rbenv --version'
|
|
||||||
check "rake" bash -c "gem list | grep rake"
|
|
||||||
|
|
||||||
# Report result
|
|
||||||
reportResults
|
|
|
@ -5,8 +5,8 @@ set -e
|
||||||
# Optional: Import test library
|
# Optional: Import test library
|
||||||
source dev-container-features-test-lib
|
source dev-container-features-test-lib
|
||||||
|
|
||||||
check "ruby" ruby -v
|
# Definition specific tests
|
||||||
check "rake" bash -c "gem list | grep rake"
|
check "rvm" rvm --version
|
||||||
|
|
||||||
# Report result
|
# Report result
|
||||||
reportResults
|
reportResults
|
13
test/ruby/non_root_user.sh
Normal file
13
test/ruby/non_root_user.sh
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Optional: Import test library
|
||||||
|
source dev-container-features-test-lib
|
||||||
|
|
||||||
|
# Definition specific tests
|
||||||
|
check "version" rvm --version
|
||||||
|
check "ruby version" ruby --version
|
||||||
|
|
||||||
|
# Report result
|
||||||
|
reportResults
|
12
test/ruby/older_version.sh
Normal file
12
test/ruby/older_version.sh
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Optional: Import test library
|
||||||
|
source dev-container-features-test-lib
|
||||||
|
|
||||||
|
# Definition specific tests
|
||||||
|
check "ruby installed" bash -c "ruby --version | grep 3.0.6"
|
||||||
|
|
||||||
|
# Report result
|
||||||
|
reportResults
|
|
@ -1,17 +1,36 @@
|
||||||
{
|
{
|
||||||
"install_additional_ruby": {
|
"non_root_user": {
|
||||||
"image": "ubuntu:focal",
|
"image": "mcr.microsoft.com/devcontainers/base:bullseye",
|
||||||
|
"remoteUser": "vscode",
|
||||||
"features": {
|
"features": {
|
||||||
"ruby": {
|
"ruby": {
|
||||||
"version": "3.1.2",
|
"version": "latest"
|
||||||
"additionalVersions": "2.5,3.0.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ruby_debian": {
|
"additional_versions": {
|
||||||
"image": "mcr.microsoft.com/devcontainers/base:bullseye",
|
"image": "mcr.microsoft.com/devcontainers/base:bullseye",
|
||||||
"features": {
|
"features": {
|
||||||
"ruby": {}
|
"ruby": {
|
||||||
|
"version": "latest",
|
||||||
|
"additionalVersions": "3.0.6,2.7.8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"older_version": {
|
||||||
|
"image": "mcr.microsoft.com/devcontainers/base:bullseye",
|
||||||
|
"features": {
|
||||||
|
"ruby": {
|
||||||
|
"version": "3.0.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"no_version": {
|
||||||
|
"image": "mcr.microsoft.com/devcontainers/base:bullseye",
|
||||||
|
"features": {
|
||||||
|
"ruby": {
|
||||||
|
"version": "none"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue