我正在运行OSX High Sierra。
我有一个ruby脚本我尝试在OSX上运行(它是一个Avid验证工具,但我认为这并不重要)。
当我运行它时,我得到以下输出(添加了代码以打印版本和gem路径)
MacBook-Pro:DTT jon$ ./run_test.command -h -v
-----
Ruby Version : 2.5.0
Gem Path :
/Users/jon/.gem/ruby/2.5.0
/Users/jon/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0
-----
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- curses (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/jon/Downloads/AAX_Tools_DSH_0p2p1x753_2/DTT/sources/DishTestTool.rb:21:in `<top (required)>'
from /Users/jon/Downloads/AAX_Tools_DSH_0p2p1x753_2/DTT/sources/bin/runsuite.rb:82:in `require_relative'
from /Users/jon/Downloads/AAX_Tools_DSH_0p2p1x753_2/DTT/sources/bin/runsuite.rb:82:in `<main>'
请注意,它似乎是从2.3版本中读取宝石,但我实际上是在运行2.5.0
如果我做gem env,则没有2.3文件夹
的迹象MacBook-Pro:DTT jon$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.0 (2017-12-25 patchlevel 0) [x86_64-darwin17]
- INSTALLATION DIRECTORY: /Users/jon/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0
- USER INSTALLATION DIRECTORY: /Users/jon/.gem/ruby/2.5.0
- RUBY EXECUTABLE: /Users/jon/.rbenv/versions/2.5.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jon/.rbenv/versions/2.5.0/bin
- SPEC CACHE DIRECTORY: /Users/jon/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/jon/.rbenv/versions/2.5.0/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-17
- GEM PATHS:
- /Users/jon/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0
- /Users/jon/.gem/ruby/2.5.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/jon/.rbenv/versions/2.5.0/bin
- /usr/local/Cellar/rbenv/1.1.1/libexec
- /Users/jon/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/local/bin
- /opt/X11/bin
我尝试用rvm安装ruby,然后卸载它,删除rvm,再次使用rbenv安装它。安装和更新宝石(特别是诅咒)等等(我是红宝石的新手,并且熟悉Unix系统的工作,但没有系统专家),但都无济于事。
有人知道我如何获得红宝石来阅读正确的宝石吗?
---------------编辑---------------- 我发现了问题的原因 ruby脚本run_test.command使用行
调用另一个ruby脚本system("#{ruby} \"#{runsuite_path.realpath}\" #{args}")
至关重要
ruby = '/usr/bin/ruby'
出于某种原因,更新ruby并不会改变使用/ usr / bin / ruby执行的ruby版本
将该行更改为
ruby = '/usr/bin/env ruby'
似乎可以解决问题
这引出了两个问题。为什么/ usr / bin / ruby没有更改以反映更新,我可以手动更改它而不会出现问题吗?
答案 0 :(得分:-1)
在/usr/bin/ruby
找到的ruby二进制文件是由MacOS安装的Ruby版本,应该保持不变。 Homebrew,Chruby,RVM&amp; RBEnv都会在远离基座的不同位置安装红宝石,这样它们就不会覆盖它或改变它。这是预期的行为,因为您不知道可能取决于系统ruby的内容,或者本机编译的内容。