新手问题 使用 rvm 安装 ruby 遇到 openssl 的问题

xinyuanjieyi · 2023年08月22日 · 最后由 Rei 回复于 2023年08月23日 · 507 次阅读

我的是 macbook pro2017 款的,版本 10.14.3

项目比较老,用的 rails3.2,我本地安装的 rvm 都是 2.4+ 的,我先用 ruby2.4.4 版本 bundle install 项目,可以正确执行

rails -v,显示 ruby 的版本版本

但是bundle exec rails s会提示错误

/Users/jieyi/.rvm/gems/ruby-2.4.4/gems/rubysl-rexml-2.0.4/lib/rexml/text.rb:35: warning: constant ::Fixnum is deprecated
/Users/jieyi/.rvm/gems/ruby-2.4.4/gems/rubysl-rexml-2.0.4/lib/rexml/xpath_parser.rb:19: warning: constant ::Fixnum is deprecated
/Users/jieyi/.rvm/gems/ruby-2.4.4/gems/CFPropertyList-2.3.1/lib/cfpropertylist/rbCFTypes.rb:24: warning: constant ::Fixnum is deprecated
/Users/jieyi/.rvm/gems/ruby-2.4.4/gems/activesupport-3.2.22.5/lib/active_support/core_ext/numeric/time.rb:50:in `*': ActiveSupport::Duration can't be coerced into Integer (TypeError)

我 google 一圈,试了很多,还是会提示这个错误,后来有人说 ruby 版本需要控制在 2.3,我本地就开始安装 ruby 2.3.3

rvm install 2.3.3,无法正常安装成功会报错,报错如下

Warning, new version of rvm available '1.29.12', you are using older version '1.29.11'.
You can disable this warning with:   echo rvm_autoupdate_flag=0 >> ~/.rvmrc
You can enable auto-update with:     echo rvm_autoupdate_flag=2 >> ~/.rvmrc
You can update manually with:        rvm get VERSION                         (e.g. 'rvm get stable')

Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.14/x86_64/ruby-2.3.3.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Installing requirements for osx.
Updating system - please wait
Failed to update Homebrew, follow instructions at

    https://docs.brew.sh/Common-Issues

and make sure `brew update` works before continuing.
Error running 'requirements_osx_brew_update_system ruby-2.3.3',
please read /Users/jieyi/.rvm/log/1692713412_ruby-2.3.3/update_system.log
Requirements installation failed with status: 1.

我用

PKG_CONFIG_PATH=/usr/local/Cellar/[email protected] \
rvm install 2.3.3 \
--with-openssl-dir=/usr/local/Cellar/[email protected] \
--with-openssl-lib=/usr/local/Cellar/[email protected] \
--with-openssl-include=/usr/local/Cellar/[email protected]

会安装成功,但是错误日志会提示rvm install 2.3.3 cannot load such file -- openssl

折腾了一天,没有折腾出来,我想请教下社区大佬,我是安装好低版本问题就好了吗,还是需要解决ActiveSupport::Duration can't be coerced into Integer问题,另外,我的电脑版本可以安装低版本了,为什么我无法关联 openssl 呢,谢谢🙏

Updating system - please wait
Failed to update Homebrew, follow instructions at

    https://docs.brew.sh/Common-Issues

and make sure `brew update` works before continuing.
Error running 'requirements_osx_brew_update_system ruby-2.3.3',
please read /Users/jieyi/.rvm/log/1692713412_ruby-2.3.3/update_system.log
Requirements installation failed with status: 1.

这里是说要让你更新 brew update,你的环境依赖比如 openssl 可能过时了

lehf 回复

好的,我在 linux 可以正常启动了

是不是还是系统的问题,我需要把系统从 10.14.3 升级到 13.5.1(macos ventura)吗

提示错误: 执行rvm install "ruby-2.3.4" -C --with-openssl-dir=$HOME/.rvm/usr或者rvm install "ruby-2.3.4"提示

28 xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command li
29 +__rvm_detect_xcode_version:25> return 0

老项目用容器或者虚拟机搭建和线上一样的环境。

Rei 回复

好的,另外我想问下 2017 款 mac pro 建议从 10.14.3 升级到 13.5.1 吗

xinyuanjieyi 回复

我还在用 2015 款的时候是有升级就升的。我的开发环境都放在 docker 里所以系统影响不大。


但如果你的开发环境是在原生环境要注意会不会一大堆东西不兼容。

xinyuanjieyi 关闭了讨论。 08月24日 09:37
xinyuanjieyi 重新开启了讨论。 08月24日 10:36
10 楼 已删除
xinyuanjieyi 关闭了讨论。 08月24日 11:33
需要 登录 后方可回复, 如果你还没有账号请 注册新账号