简体   繁体   中英

Cannot install old ruby version

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/openssl@1.1/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/openssl@1.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/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/openssl@1.1/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/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"

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 openssl@1.1 . The errors included:

For compilers to find openssl@1.1 you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM