可以“gem install"吗?是否配置为默认在/usr/bin/之外安装可执行文件? [英] Can "gem install" be configured to install executables outside /usr/bin/ by default?

查看:9
本文介绍了可以“gem install"吗?是否配置为默认在/usr/bin/之外安装可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,当您 sudo gem install thegemname 时,它会将可执行文件安装到 /usr/bin/

By default, when you sudo gem install thegemname it will install executables into /usr/bin/

有没有办法改变这种情况?例如,要将它们安装到 /usr/local/rubygems/bin (或任何其他路径)?

Is there a way to change this? For example, to install them into /usr/local/rubygems/bin (or any other path)?

路径似乎没有硬编码到 gemspec 文件中,所以我不明白为什么这是不可能的(尽管我对 Ruby/Gems 的经验很少)

The path doesn't seem to be hard-coded into the gemspec file, so I don't see why this shouldn't be possible (although I have very little experience with Ruby/Gems)

推荐答案

参见 http://www.rubygems.org/read/chapter/11 并指定一个定义 gemhome 变量的 ~/.gemrc.

See http://www.rubygems.org/read/chapter/11 and specify a ~/.gemrc which defines a gemhome variable.

例如:

gemhome: /usr/local/rubygems

你也可以把这个文件放在/etc/gemrc

You can also place this file in /etc/gemrc

或者,您可以设置 GEM_HOME 环境变量:

Alternatively you can set the GEM_HOME env-variable:

$ export GEM_HOME=/tmp/gemtest
$ gem install bundler
$ ls /tmp/gemtest/bin/
bundle

更新(10 年后):

Andrey Rodionov 下面建议使用

Andrey Rodionov below suggest using

gem: --bindir /usr/bin

这篇关于可以“gem install"吗?是否配置为默认在/usr/bin/之外安装可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆