Eclipse(在OS X 10.9上)默认为内置Ruby 2.0但需要1.8.7

时间:2020-11-26 02:42:17

On my MacBook Pro with OS X 10.9 (Mavericks) installed, Eclipse is stuck on using the built-in Ruby 2.0.0 which breaks the ruby script I use as part of my build.

在安装了OS X 10.9(Mavericks)的MacBook Pro上,Eclipse坚持使用内置的Ruby 2.0.0,它打破了我在构建过程中使用的ruby脚本。

What I've done

我做了什么

  • I've used rvm and installed 1.8.7
  • 我用过rvm并安装了1.8.7

  • I've updated ~/.bash_profile to include rvm use 1.8.7
  • 我更新了〜/ .bash_profile以包含rvm use 1.8.7

  • In Project Properties -> Builders -> The ruby script has an entry: Location indicates where the script it, Working Directory indicates the folder that contains the source data and where the processed data will be saved in, Arguments is the command-line arguments
  • 在项目属性 - >构建器 - > ruby​​脚本中有一个条目:位置指示脚本的位置,工作目录指示包含源数据的文件夹以及保存处理数据的位置,参数是命令行参数

What I'm getting

我得到了什么

  • When I open a new bash terminal I see the message Using ~/.rvm/gems/ruby-1.8.7-p374

    当我打开一个新的bash终端时,我看到消息使用〜/ .rvm / gems / ruby​​-1.8.7-p374

  • When Eclipse shows the error in the console window, it shows : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in "require": cannot load such file -- plist (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in "require" from .....

    当Eclipse在控制台窗口中显示错误时,它显示:/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in“ require“:无法从/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in加载此类文件 - plist(LoadError)来自......的“要求”

  • When I execute the ruby script from a terminal, it executes just fine.

    当我从终端执行ruby脚本时,它执行得很好。

Problem

  • It seems that Eclipse isn't using the ruby 1.8.7 that I've installed - how can I change that ?
  • 似乎Eclipse没有使用我安装的ruby 1.8.7 - 我怎么能改变它?

EDIT... my ~/.bash_profile is as follows :

编辑...我的〜/ .bash_profile如下:

export PATH=$PATH:/Android/adt-bundle-mac-x86_64-20131030/sdk/tools
export PATH=$PATH:/usr/local/bin:$PATH #sublime
export PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
rvm use 1.8.7-p374

2 个解决方案

#1


2  

Since Eclipse insists on using the system ruby (and ignoring my RVM installed Ruby - which was not an issue in OS X 10.7.5 !), I decided to stop fighting it... sudo /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/gem install plist got me the gem I needed

由于Eclipse坚持使用系统ruby(而忽略了我的RVM安装的Ruby - 这在OS X 10.7.5中不是问题!),我决定不再与它斗争了... sudo /System/Library/Frameworks/Ruby.framework /Versions/2.0/usr/bin/gem安装plist给了我所需的宝石

#2


1  

You have to tell rvm which ruby version to use:

你必须告诉rvm使用哪个ruby版本:

rvm use 1.8.7-p<package_number>

Moreover, assuming you want Ruby 1.8.7 to be your default version as well, you may consider:

此外,假设您希望Ruby 1.8.7也是您的默认版本,您可以考虑:

rvm alias create default 1.8.7-p<package_number>

To perform both operations with 1 command:

要使用1命令执行这两个操作:

rvm --default use 1.8.7-p<package_number>

More information on selecting a default ruby version with rvm can be found here: http://rvm.io/rubies/default

有关使用rvm选择默认ruby版本的更多信息,请访问:http://rvm.io/rubies/default

Update: Rather than the .bash_profile, you want to add the 'rvm use 1.8.7-p' command to your .rvmrc or .ruby-version + .ruby-gemset file(s) in the project directory that you want the gemset to apply to; more on creating a .rvmrc/.ruby-version+.ruby-gemset file here: http://rvm.io/workflow/projects

更新:而不是.bash_profile,您希望将'rvm use 1.8.7 -p'命令添加到项目目录中您希望gemset的.rvmrc或.ruby-version + .ruby-gemset文件中申请;更多关于在这里创建.rvmrc / .ruby-version + .ruby-gemset文件:http://rvm.io/workflow/projects

#1


2  

Since Eclipse insists on using the system ruby (and ignoring my RVM installed Ruby - which was not an issue in OS X 10.7.5 !), I decided to stop fighting it... sudo /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/gem install plist got me the gem I needed

由于Eclipse坚持使用系统ruby(而忽略了我的RVM安装的Ruby - 这在OS X 10.7.5中不是问题!),我决定不再与它斗争了... sudo /System/Library/Frameworks/Ruby.framework /Versions/2.0/usr/bin/gem安装plist给了我所需的宝石

#2


1  

You have to tell rvm which ruby version to use:

你必须告诉rvm使用哪个ruby版本:

rvm use 1.8.7-p<package_number>

Moreover, assuming you want Ruby 1.8.7 to be your default version as well, you may consider:

此外,假设您希望Ruby 1.8.7也是您的默认版本,您可以考虑:

rvm alias create default 1.8.7-p<package_number>

To perform both operations with 1 command:

要使用1命令执行这两个操作:

rvm --default use 1.8.7-p<package_number>

More information on selecting a default ruby version with rvm can be found here: http://rvm.io/rubies/default

有关使用rvm选择默认ruby版本的更多信息,请访问:http://rvm.io/rubies/default

Update: Rather than the .bash_profile, you want to add the 'rvm use 1.8.7-p' command to your .rvmrc or .ruby-version + .ruby-gemset file(s) in the project directory that you want the gemset to apply to; more on creating a .rvmrc/.ruby-version+.ruby-gemset file here: http://rvm.io/workflow/projects

更新:而不是.bash_profile,您希望将'rvm use 1.8.7 -p'命令添加到项目目录中您希望gemset的.rvmrc或.ruby-version + .ruby-gemset文件中申请;更多关于在这里创建.rvmrc / .ruby-version + .ruby-gemset文件:http://rvm.io/workflow/projects