CircleCI-Public / ruby-orb

The `circleci/ruby` orb source code.
https://circleci.com/developer/orbs/orb/circleci/ruby
MIT License
26 stars 53 forks source link

Installing EoL'ed Ruby (e.g., 2.6.x) via RVM throws Error running '__rvm_make' error when user is root #137

Closed kelvintaywl closed 7 months ago

kelvintaywl commented 9 months ago

Orb version: 2.1.1

What happened:

I have an execution environment (e.g., self-hosted Machine Runner) where the user is root. In addition, the OpenSSL version available is 3.0.2. I tried using the Ruby orb to install an EoL Ruby version (e.g., 2.6.10) like below:

# .circleci/config.yml

version: 2.1

orbs:
  ruby: circleci/ruby@2.1.1

jobs:
  test:
    machine: true
    resource_class: kelvintaywl-cci/ec2-machine-runner3-ubuntu2204-tf
    steps:
      - run: lsb_release -a
      - run: whoami
      - checkout
      - ruby/install:
          version: '2.6.10'
      - ruby/install-deps

The following error is seen:

ruby-2.6.10 - #extracting ruby-2.6.10 to /usr/local/rvm/src/ruby-2.6.10.....
ruby-2.6.10 - #configuring.......................................................................
ruby-2.6.10 - #post-configuration..
ruby-2.6.10 - #compiling...........................................................................................|
Error running '__rvm_make -j2',
please read /usr/local/rvm/log/1707874351_ruby-2.6.10/make.log

There has been an error while running make. Halting the installation.

Exited with code exit status 2

For reference:

Expected behavior:

EoL'ed Ruby versions should still be installable when ruby/install.

Additional Information:

We addressed the RVM home location for root in this PR: https://github.com/CircleCI-Public/ruby-orb/pull/90

However, the same reference, for where RVM home is, was not applied when we addressed the OpenSSL compatibility: https://github.com/CircleCI-Public/ruby-orb/pull/116

I believe this error can be fixed if we update areas referencing --with-openssl-dir like so:

# this follows the changes made for https://github.com/CircleCI-Public/ruby-orb/pull/90/files
- WITH_OPENSSL="--with-openssl-dir=$HOME/.rvm/usr
+ RVM_HOME=$HOME/.rvm
+ if [ -f "$RVM_HOME/scripts/rvm" ]; then
+   echo "Using $RVM_HOME"
+ else
+   RVM_HOME=/usr/local/rvm
+   echo "Using $RVM_HOME"
+ fi
+ WITH_OPENSSL="--with-openssl-dir=$RVM_HOME/usr

I observed that RVM is installed under /usr/local/rvm when user is root, as also mentioned in #90: https://app.circleci.com/pipelines/github/kelvintaywl-cci/machine-runner-explore/35/workflows/c7f57584-17fc-45b9-875a-afd2384905a7/jobs/45?invite=true#step-104-1915_20