Skip to content

Commit

Permalink
Ruby Feature [bug fix] : Fails if the dev container has the same ruby…
Browse files Browse the repository at this point in the history
… version installed (#609)

* Ruby Feature [bug fix] : Fails if the dev container has the same ruby version installed

* add comment

* remove scenario
  • Loading branch information
samruddhikhandale authored Aug 16, 2023
1 parent f90cb26 commit 1d1a236
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ruby/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "ruby",
"version": "1.1.0",
"version": "1.1.1",
"name": "Ruby (via rvm)",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/ruby",
"description": "Installs Ruby, rvm, rbenv, common Ruby utilities, and needed dependencies.",
Expand Down
16 changes: 12 additions & 4 deletions src/ruby/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,11 @@ fi
find_version_from_git_tags RUBY_VERSION "https://github.com/ruby/ruby" "tags/v" "_"

# Just install Ruby if RVM already installed
if [ $(rvm --version) != "" ]; then
if rvm --version > /dev/null; then
echo "Ruby Version Manager already exists."
if [ "${RUBY_VERSION}" != "none" ]; then
if [[ "$(ruby -v)" = *"${RUBY_VERSION}"* ]]; then
echo "(!) Ruby is already installed with version ${RUBY_VERSION}. Skipping..."
elif [ "${RUBY_VERSION}" != "none" ]; then
echo "Installing specified Ruby version."
su ${USERNAME} -c "rvm install ruby ${RUBY_VERSION}"
fi
Expand All @@ -191,6 +193,9 @@ else
# Determine appropriate settings for rvm installer
if [ "${RUBY_VERSION}" = "none" ]; then
RVM_INSTALL_ARGS=""
elif [[ "$(ruby -v)" = *"${RUBY_VERSION}"* ]]; then
echo "(!) Ruby is already installed with version ${RUBY_VERSION}. Skipping..."
RVM_INSTALL_ARGS=""
else
if [ "${RUBY_VERSION}" = "latest" ] || [ "${RUBY_VERSION}" = "current" ] || [ "${RUBY_VERSION}" = "lts" ]; then
RVM_INSTALL_ARGS="--ruby"
Expand Down Expand Up @@ -273,8 +278,11 @@ if [ "${SKIP_RBENV_RBUILD}" != "true" ]; then
ln -s /usr/local/share/ruby-build /home/${USERNAME}/.rbenv/plugins/ruby-build
fi

ln -s /usr/local/rvm/rubies/default/bin/ruby /usr/local/rvm/gems/default/bin

# 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
Expand Down

0 comments on commit 1d1a236

Please sign in to comment.