aboutsummaryrefslogtreecommitdiff
path: root/src/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'src/ruby')
-rw-r--r--src/ruby/install.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/ruby/install.sh b/src/ruby/install.sh
index f4c7b10..5152893 100644
--- a/src/ruby/install.sh
+++ b/src/ruby/install.sh
@@ -167,6 +167,14 @@ check_packages() {
fi
}
+sudo_if() {
+ COMMAND="$*"
+ if [ "$(id -u)" -eq 0 ] && [ "$USERNAME" != "root" ]; then
+ su - "$USERNAME" -c "$COMMAND"
+ else
+ "$COMMAND"
+ fi
+}
# Ensure apt is in non-interactive to avoid prompts
export DEBIAN_FRONTEND=noninteractive
@@ -271,11 +279,15 @@ if [ "${SKIP_RBENV_RBUILD}" != "true" ]; then
if [ "${USERNAME}" != "root" ]; then
mkdir -p /home/${USERNAME}/.rbenv/plugins
- chown -R ${USERNAME} /home/${USERNAME}/.rbenv
+ sudo_if chown -R ${USERNAME} /home/${USERNAME}/.rbenv
+ sudo_if chown -R ${USERNAME} /usr/local/rvm/
if [[ ! -d "/home/${USERNAME}/.rbenv/plugins/ruby-build" ]]; 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
+
fi
fi