ruby-orb icon indicating copy to clipboard operation
ruby-orb copied to clipboard

Errors on non circle images - runs as root and sources wrong bash profile

Open kieran-osgood opened this issue 3 years ago • 0 comments

Orb version:

0.2.2

What happened:

There's seems to be an issue with the installation when using non-circle provided images as it will attempt to source the bash profile from root providing this error:

rvm install 2.7
rvm use 2.7
echo . $(rvm 2.7 do rvm env --path) >> $BASH_ENV

/tmp/.bash_env-60a2b2cc3b59b77b9bec7a64-0-build: line 2: /root/.rvm/scripts/rvm: No such file or directory
/bin/bash: rvm: command not found

Exited with code exit status 127

I'd contacted circle support and this was the response:

I believe the issue here with RVM is that the installation is run as the root as opposed to an unprivileged user or with sudo. The Orb does not appear to account for that. I've created a custom run step based on the Orb that should get RVM installed and running on that image. I also removed a few parts for brevity.

      - run: |
          # Disable IPv6
          mkdir -p ~/.gnupg/
          find ~/.gnupg -type d -exec chmod 700 {} \;
          echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf
          until gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
          curl -sSL "https://get.rvm.io" | bash -s stable
          # this should be what needs to be added to that $BASH_ENV since this is what's in bash_profile - i dont know when $HOME is set
          echo "source /etc/profile.d/rvm.sh" >> $BASH_ENV
          # this will source if anyone logs in noninteractively, nvm setup only adds nvm to the path, to get the rubygems later you need to source this again
          echo "source /etc/profile.d/rvm.sh" >> .bashrc
      - run: |
          rvm install 2.7
          rvm use 2.7
The only thing that actually needed to change here was the source commands. The Orb makes use of the following based upon a user install:

echo "source $HOME/.rvm/scripts/rvm" >> $BASH_ENV
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bashrc
I changed that to make use of the multi-user installation location for RVM:

echo "source /etc/profile.d/rvm.sh" >> $BASH_ENV
echo "source /etc/profile.d/rvm.sh" >> .bashrc

Expected behavior:

Conditional logic to select the correct bash profile and run it at such

kieran-osgood avatar May 20 '21 09:05 kieran-osgood