如何更改在OS 10.6.6 ruby 1.8和Rails 3上安装ruby gems的路径

时间:2022-01-29 07:11:46

Whether I use gem install or bundle install for my gems, they don't work. Sometimes sudo gem install gets gems to work. I ran the gem list -d and which gem commands, and it seems that my system is configured such that all the gems get installed into " /Library/Ruby/Gems/1.8" but my environment expects them in "/usr/bin/gem". How could I properly correct this? I was under the impression that 'bundle' should be able to install a local, application specific copy of a gem?

无论我使用gem安装还是绑定安装,它们都不起作用。有时sudo gem安装可以让gems工作。我运行了gem列表-d和哪个gem命令,看起来我的系统配置得很好,所有的gem都被安装到“/Library/Ruby/ gems /1.8”中,但是我的环境期望它们在“/usr/bin/gem”中。我怎么能正确地改正这个?我的印象是,“bundle”应该能够安装本地、应用程序特定的gem副本?

2 个解决方案

#1


4  

I would suggest using RVM (Ruby Version Manager) to control which version of Ruby you are installing your gems into. It will also help keep all the bundle and gem data in a folder in your home directory.

我建议使用RVM (Ruby版本管理器)来控制您将宝石安装到的Ruby版本。它还将帮助将所有bundle和gem数据保存在主目录中的文件夹中。

#2


12  

Although many Rubyists will recommend you RVM or RBENV, I do not use it. It's VERY slow and it pollutes your environment.

虽然许多反刍动物会推荐你使用RVM或RBENV,但我不使用它。它非常慢,污染你的环境。

If you use Bundler, you dont need RVM at all - rubygem itself supports multiple versions of single gems. So you can just start using gems (e.g. gem install etc) and it will install into your $HOME/.gem directory by default. You can check the installation path using:

如果您使用Bundler,则完全不需要RVM—rubygem本身支持多个版本的单个gem。所以你可以开始使用gems(例如gem安装等),它会安装到你的$HOME/中。宝石默认目录。您可以使用以下方法检查安装路径:

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.25
  - RUBY VERSION: 1.9.3 (2013-02-06 patchlevel 385) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/lzap/.gem/ruby/1.9.3
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /home/lzap/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/lzap/.gem/ruby/1.9.3
     - /usr/share/gems
     - /usr/local/share/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "install" => "--no-rdoc --no-ri"
  - REMOTE SOURCES:
     - http://rubygems.org/

You can even change this with GEM_HOME environment variable. Happy gemming!

您甚至可以使用GEM_HOME环境变量来更改它。gemming快乐!

#1


4  

I would suggest using RVM (Ruby Version Manager) to control which version of Ruby you are installing your gems into. It will also help keep all the bundle and gem data in a folder in your home directory.

我建议使用RVM (Ruby版本管理器)来控制您将宝石安装到的Ruby版本。它还将帮助将所有bundle和gem数据保存在主目录中的文件夹中。

#2


12  

Although many Rubyists will recommend you RVM or RBENV, I do not use it. It's VERY slow and it pollutes your environment.

虽然许多反刍动物会推荐你使用RVM或RBENV,但我不使用它。它非常慢,污染你的环境。

If you use Bundler, you dont need RVM at all - rubygem itself supports multiple versions of single gems. So you can just start using gems (e.g. gem install etc) and it will install into your $HOME/.gem directory by default. You can check the installation path using:

如果您使用Bundler,则完全不需要RVM—rubygem本身支持多个版本的单个gem。所以你可以开始使用gems(例如gem安装等),它会安装到你的$HOME/中。宝石默认目录。您可以使用以下方法检查安装路径:

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.25
  - RUBY VERSION: 1.9.3 (2013-02-06 patchlevel 385) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/lzap/.gem/ruby/1.9.3
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /home/lzap/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/lzap/.gem/ruby/1.9.3
     - /usr/share/gems
     - /usr/local/share/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "install" => "--no-rdoc --no-ri"
  - REMOTE SOURCES:
     - http://rubygems.org/

You can even change this with GEM_HOME environment variable. Happy gemming!

您甚至可以使用GEM_HOME环境变量来更改它。gemming快乐!