Skip to content

Commit 69cba4f

Browse files
ruby: install additional versions (#57)
* ruby: install additional versions * nit: fixing spelling Co-authored-by: Josh Spicer <joshspicer@github.com>
1 parent 6eab72c commit 69cba4f

4 files changed

Lines changed: 40 additions & 4 deletions

File tree

src/ruby/devcontainer-feature.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,5 @@
2424
"GEM_HOME": "/usr/local/rvm/gems/default",
2525
"MY_RUBY_HOME": "/usr/local/rvm/rubies/default",
2626
"PATH": "/usr/local/rvm/gems/default/bin:/usr/local/rvm/gems/default@global/bin:/usr/local/rvm/rubies/default/bin:${PATH}"
27-
},
28-
"install": {
29-
"app": "",
30-
"file": "install.sh"
3127
}
3228
}

src/ruby/install.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ USERNAME=${USERNAME:-"automatic"}
1313
UPDATE_RC=${UPDATE_RC:-"true"}
1414
INSTALL_RUBY_TOOLS=${INSTALL_RUBY_TOOLS:-"true"}
1515

16+
# Comma-separated list of ruby versions to be installed (with rvm)
17+
# alongside RUBY_VERSION, but not set as default.
18+
ADDITIONAL_VERSIONS=${ADDITIONAL_VERSIONS:-""}
19+
1620
# Note: ruby-debug-ide will install the right version of debase if missing and
1721
# installing debase directly fails on Ruby 3.1.0 as of 1/7/2022, so omitting.
1822
DEFAULT_GEMS="rake ruby-debug-ide"
@@ -239,6 +243,20 @@ fi
239243
# VS Code server usually first in the path, so silence annoying rvm warning (that does not apply) and then source it
240244
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"
241245

246+
# Additional ruby versions to be installed but not be set as default.
247+
if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
248+
OLDIFS=$IFS
249+
IFS=","
250+
read -a additional_versions <<< "$ADDITIONAL_VERSIONS"
251+
for version in "${additional_versions[@]}"; do
252+
# Figure out correct version of a three part version number is not passed
253+
find_version_from_git_tags version "https://github.com/ruby/ruby" "tags/v" "_"
254+
source /usr/local/rvm/scripts/rvm
255+
rvm install ruby ${version}
256+
done
257+
IFS=$OLDIFS
258+
fi
259+
242260
# Install rbenv/ruby-build for good measure
243261
if [ "${SKIP_RBENV_RBUILD}" != "true" ]; then
244262

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library
6+
source dev-container-features-test-lib
7+
8+
check "ruby version 3.1.2 installed as default" ruby -v | grep 3.1.2
9+
check "ruby version 2.5.9 installed" rvm list | grep 2.5.9
10+
check "ruby version 3.0.4 installed" rvm list | grep 3.0.4
11+
12+
# Report result
13+
reportResults

test-scenarios/scenarios.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,14 @@
1111
"configure_jupyterlab_allow_origin": "*"
1212
}
1313
}
14+
},
15+
"install_additional_ruby": {
16+
"image": "ubuntu:focal",
17+
"features": {
18+
"ruby": {
19+
"version": "3.1.2",
20+
"additional_versions": "2.5,3.0.4"
21+
}
22+
}
1423
}
1524
}

0 commit comments

Comments
 (0)