Cannot install old ruby version

855 views Asked by At

I am unable to install ruby 2.4.2

My setup must allow me to use nvm and rvm, and I need to use ruby versions 2.7.2 and 2.4.2. I suspect you may find multiple problems with my openssl and rvm setup. Also, I am not sure which version of openssl is appropriate for me. I am using macOS Monterey Version 12.3.1.

When I do:

  rvm install 2.4.2

I see this error in my ..._ruby-2.4.2/configure.log

configure: error: something wrong with LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"

The following info may relate to the problem:

openssl version # LibreSSL 2.8.3

~/.zshrc

export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH="/opt/homebrew/bin:$PATH"
export PATH="/opt/homebrew/sbin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
export ZSH="$HOME/.oh-my-zsh"
HIST_STAMPS="dd/mm/yyyy"
plugins=(git)
source $ZSH/oh-my-zsh.sh
export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
export RUBY_CFLAGS="-DUSE_FFI_CLOSURE_ALLOC"

~/.bashrc

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" 
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  
export PATH="$PATH:$HOME/.rvm/bin"

~/.bash_profile

PATH="~/.rvm/gems/ruby-2.7.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin/sqlite3:$PATH"
export NVM_DIR=~/.nvm

source ~/.bashrc

# Disabled the next line
# source ~/.profile

alias start_puma="bundle exec puma -p 3000 -S ~/puma -C config/puma.rb"

parse_git_branch() {
  git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
setopt PROMPT_SUBST
export PROMPT='%F{grey}%n%f %F{cyan}%~%f %F{green}$(parse_git_branch)%f %F{normal}$%f '

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
1

There are 1 answers

0
user3724786 On

I identified two problems:

  1. My LDFLAGS had the wrong path in ~/.zshrc
  2. I did not understand why openssl version produced LibreSSL 2.8.3

I found the correct path to the LDFLAGS within the errors produced by brew reinstall [email protected]. The errors included:

For compilers to find [email protected] you may need to set:
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

The response to openssl version is still LibreSSL 2.8.3 and I assume this is correct.

I have also learned that ~/.zshrc must include source ~/.bash_profile, and that ~/.bash_profile must include source ~/.bashrc.

I am now able to open a new shell window and see the correct results for rvm list (listing the available ruby versions) and nvm list (listing the available node versions).

I am also able to install the ruby versions I want.