在本地文件夹中安装gem [英] Install gem in local folder
问题描述
我对我使用的共享机器拥有有限的权限,因此无法按照我习惯的方式安装宝石。例如:
I have limited privileges on a shared machine I'm using, so I can't install gems the way I'm used to. For example:
$ gem install request-log-analyzer
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/lib/ruby/gems/1.8 directory.
是否可以在本地安装gem? (如果重要,我正在尝试安装这个宝石。)
Is it possible to install a gem locally? (if it matters, I'm trying to install this gem.)
我在Stack Overflow上看到很多关于使用Bundler或gemfiles的文章,但我没有为Ruby on Rails项目安装这个gem - 我只是想孤立地使用它。
I saw a number of posts on Stack Overflow that talked about using Bundler or gemfiles but I'm not installing this gem for a Ruby on Rails project - I just want to use it in isolation.
我正在运行Linux,不知道它是哪一种。
I'm running Linux, not sure which flavor though.
推荐答案
将 - 本地
标志添加到您的安装中:
Add the --local
flag to your install:
gem install --local request-log-analyzer
如果导致任何问题,请手动下载gem并使用以下命令将 gem
直接指向它:
If that causes any problems, try downloading the gem manually and pointing gem
directly to it using:
gem install --local path/to/gem/filename.gem
如果您想将其安装到您的用户主目录每 rubygems :
If you want to install it to your user home, as per rubygems:
当你使用--user-install选项,RubyGems会将gems
安装到你的主目录内的一个目录,比如
〜/ .gem / ruby / 1.9.1。您安装
的gems提供的命令将以〜/ .gem / ruby / 1.9.1 / bin结尾。对于安装了
的程序,您需要将〜/ .gem / ruby / 1.9.1 / bin添加到您的
PATH环境变量中。
When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/.gem/ruby/1.9.1. The commands provided by the gems you installed will end up in ~/.gem/ruby/1.9.1/bin. For the programs installed there to be available for you, you need to add ~/.gem/ruby/1.9.1/bin to your PATH environment variable.
这个命令只是
The command for this would just be
gem install --user-install request-log-analyzer
这篇关于在本地文件夹中安装gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!