Ruby Feature [bug fix] : Fails if the dev container has the same ruby version installed (#609)

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

* add comment

* remove scenario
This commit is contained in:
Samruddhi Khandale 2023-08-16 11:38:35 -07:00 committed by GitHub
parent f90cb26c7f
commit 1d1a23625d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View file

@ -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.",

View file

@ -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
@ -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"
@ -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