简体   繁体   English

无法安装旧的 ruby​​ 版本

[英]Cannot install old ruby version

I am unable to install ruby 2.4.2我无法安装 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 .我的设置必须允许我使用nvmrvm ,并且我需要使用 ruby​​ 版本2.7.22.4.2 I suspect you may find multiple problems with my openssl and rvm setup.我怀疑您可能会发现我的opensslrvm设置存在多个问题。 Also, I am not sure which version of openssl is appropriate for me.另外,我不确定哪个版本的openssl适合我。 I am using macOS Monterey Version 12.3.1 .我正在使用macOS Monterey版本12.3.1

When I do:当我做:

 rvm install 2.4.2

I see this error in my ..._ruby-2.4.2/configure.log我在我的 ..._ruby-2.4.2/configure.log 中看到了这个错误

configure: error: something wrong with LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"配置:错误:LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib" 有问题

The following info may relate to the problem:以下信息可能与该问题有关:

openssl version # LibreSSL 2.8.3 openssl 版本#LibreSSL 2.8.3

~/.zshrc ~/.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 ~/.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 ~/.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我的 LDFLAGS 在 ~/.zshrc 中有错误的路径
  2. I did not understand why openssl version produced LibreSSL 2.8.3我不明白为什么openssl version产生LibreSSL 2.8.3

I found the correct path to the LDFLAGS within the errors produced by brew reinstall openssl@1.1 .我在brew reinstall openssl@1.1产生的错误中找到了LDFLAGS的正确路径。 The errors included:错误包括:

For compilers to find openssl@1.1 you may need to set:要让编译器找到 openssl@1.1,您可能需要设置:
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"导出 LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"导出 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.openssl version的响应仍然是LibreSSL 2.8.3 ,我认为这是正确的。

I have also learned that ~/.zshrc must include source ~/.bash_profile , and that ~/.bash_profile must include source ~/.bashrc .我还了解到~/.zshrc必须包含source ~/.bash_profile ,并且~/.bash_profile必须包含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).我现在可以打开一个新的 shell 窗口并查看rvm list (列出可用的 ruby​​ 版本)和nvm list (列出可用的节点版本)的正确结果。

I am also able to install the ruby versions I want.我还可以安装我想要的 ruby​​ 版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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