为什么RubyMine和终端中的gem环境不同

时间:2014-03-23 21:07:00

标签: ruby-on-rails rubygems gem rubymine

我的终端宝石环境与我的Rubymine环境不匹配。 在终端,它给出:

  - EXECUTABLE DIRECTORY: /Users/george/.gem/ruby/1.9.3/bin
  - SPEC CACHE DIRECTORY: /Users/george/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-12
  - GEM PATHS:
     - /Users/george/.gem/ruby/1.9.3
     - /Users/george/.rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1

而在RubyMine中它给出了:

EXECUTABLE DIRECTORY: /Users/george/.rubies/ruby-1.9.3-p392/bin
SPEC CACHE DIRECTORY: /Users/george/.gem/specs
RUBYGEMS PLATFORMS:
  ruby
  x86_64-darwin-12
GEM PATHS:
   /Users/george/.rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1
   /Users/george/.gem/ruby/1.9.1

似乎有关于宝石位置的混淆,我不知道如何解决它。

我正在使用chruby来控制安装了ruby-build的ruby版本 该应用程序是Rails 3.2.17

终端和Rubymine的完整输出如下:

终端:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 1.9.3 (2013-02-22 patchlevel 392) [x86_64-darwin12.5.0]
  - INSTALLATION DIRECTORY: /Users/george/.gem/ruby/1.9.3
  - RUBY EXECUTABLE: /Users/george/.rubies/ruby-1.9.3-p392/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/george/.gem/ruby/1.9.3/bin
  - SPEC CACHE DIRECTORY: /Users/george/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-12
  - GEM PATHS:
     - /Users/george/.gem/ruby/1.9.3
     - /Users/george/.rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/george/.gem/ruby/1.9.3/bin
     - /Users/george/.rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1/bin
     - /Users/george/.rubies/ruby-1.9.3-p392/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/bin
     - /Users/george/bin
     - /opt/X11/bin

的RubyMine:

RUBYGEMS VERSION: 2.2.2
RUBY VERSION: 1.9.3 (2013-02-22 patchlevel 392) [x86_64-darwin12.5.0]
INSTALLATION DIRECTORY: /Users/george/.rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1
RUBY EXECUTABLE: /Users/george/.rubies/ruby-1.9.3-p392/bin/ruby
EXECUTABLE DIRECTORY: /Users/george/.rubies/ruby-1.9.3-p392/bin
SPEC CACHE DIRECTORY: /Users/george/.gem/specs
RUBYGEMS PLATFORMS:
  ruby
  x86_64-darwin-12
GEM PATHS:
   /Users/george/.rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1
   /Users/george/.gem/ruby/1.9.1
GEM CONFIGURATION:
   :update_sources => true
   :verbose => true
   :backtrace => false
   :bulk_threshold => 1000
REMOTE SOURCES:
   https://rubygems.org/
SHELL PATH:
   /Users/george/.rubies/ruby-1.9.3-p392/bin
   /usr/bin
   /bin
   /usr/sbin
   /sbin
   /usr/local/bin
   /Users/george/bin
   /opt/X11/bin
   /usr/local/bin
----------------------
IDE: RubyMine 6.0.3, build #RM-133.632
OS: Mac OS X 10.9.2[x86_64]
Java: 1.6.0_65-b14-462-11M4609
RubyMine SDK Environment:
Sdk: ruby-1.9.3-p392
Sdk Version: ver.1.9.3p392 ( revision 39386) p392
Ruby Interpreter: /Users/george/.rubies/ruby-1.9.3-p392/bin/ruby
RVM Sdk: no
RVM Home: /usr/local/rvm
Sdk Language Level: 1.9
Sdk Load Path:
     ~/.rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1
     ~/.rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/x86_64-darwin12.5.0
     ~/.rubies/ruby-1.9.3-p392/lib/ruby/site_ruby
     ~/.rubies/ruby-1.9.3-p392/lib/ruby/vendor_ruby/1.9.1
     ~/.rubies/ruby-1.9.3-p392/lib/ruby/vendor_ruby/1.9.1/x86_64-darwin12.5.0
     ~/.rubies/ruby-1.9.3-p392/lib/ruby/vendor_ruby
     ~/.rubies/ruby-1.9.3-p392/lib/ruby/1.9.1
     ~/.rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/x86_64-darwin12.5.0
     /Applications/RubyMine.app/rubystubs193
Sdk Gem paths: 
     ~/.rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1/gems
     ~/.gem/ruby/1.9.1/gems
     ~/.rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1/bundler/gems
     ~/.gem/ruby/1.9.1/bundler/gems

2 个答案:

答案 0 :(得分:3)

似乎RubyMine使用了错误的ruby版本。解决这个问题:

  1. 在RubyMine中转到首选项 - > Ruby SDK和Gems
  2. 点击中间窗口中的红宝石
  3. 然后单击右侧窗口中的任何gem并检查底部窗口中的gem路径
  4. 如果路径与您在终端中的路径不一致
  5. 在中间窗口中单击+,选择New local ...并将路径添加到所需的ruby bin目录。 这应该可以解决问题。

答案 1 :(得分:0)

默认情况下,RubyMine在项目根目录中搜索文件.ruby-version,然后设置要与rvm一起使用的Ruby版本,覆盖默认的rvm配置。

要解决此问题,您有两个选择:

  • .ruby-version文件编辑为所需的版本。
  • o @ anton-chikin说,您可以手动更改RubyMine中使用的SDK - >偏好 - > Ruby SDK和Gems