如何使用rbenv在没有sudo的情况下全局安装gem? [英] How to install a gem globally without sudo using rbenv?

查看:168
本文介绍了如何使用rbenv在没有sudo的情况下全局安装gem?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 rbenv ,并试图安装 sass ,但没有成功。



因此,我通过自制软件安装 rbenv ,然后是Ruby 2.2( rbenv install 2.2 ),最后是 gem install sass ,但我无法使<$我的 $ PATH



可用的c $ c> sass 我使用我的系统(Yosemite)默认的Ruby 2安装了sa sudo gem install sass 。这将所有内容放在 /Library/Ruby/Gems/2.0.0中。
$ b

理想情况下,使用 rbenv ,并且事情能够工作,但不是最理想的方式。我应该能够安装任何Ruby版本,并且在该版本的目录中安装gems,然后将它们symlink到 / usrl / local / bin



任何可能出错的帮助都将非常值得赞赏。

解决方案

基本上,问题我没有将 rbenv / bin / rbenv 添加到 $ PATH

  export PATH =$ HOME / .rbenv / bin:$ PATH

更好的是,将它添加到 .bashrc .bash_profile 中,使用<$ c开始每个会话

$ p
$ b

然后,请确保:

<$ p $
p> eval$(rbenv init - )

shims和autocompletion。

fishshell



对于那些使用鱼的人来说,你可以像这样完成: p>

  if status --is-interactive 
。 (rbenv init - | psub)
end

现在,如果您不喜欢修改 $ PATH ,并拥有 / usr / local / bin 的所有权,一个更好的解决方案是使用〜/ .rbenv / bin / rbenv

  ln -s〜/。 rbenv / bin / rbenv / usr / local / bin 



ruby​​-build



作为最终警告,请确保安装 ruby​​-建立 (a rbenv 插件将安装命令添加到 rbenv 并且能够轻松安装Ruby版本。)



如果您使用 homebrew 这很容易:

  brew install ruby​​-build 


I am using rbenv and I am trying to install sass without success.

So, I installed rbenv via Homebrew, then Ruby 2.2 (rbenv install 2.2) and finally gem install sass, but I was unable to make sass available on my $PATH.

Short on time, I sudo gem install sass using my system's (Yosemite) default Ruby 2. This put everything in /Library/Ruby/Gems/2.0.0 and things do work, but not in the most desireable way.

Ideally, using rbenv I should be able to install any Ruby version and have gems installed inside that version's directory and later symlinked to /usrl/local/bin.

Any help as to what could have gone wrong would be very much appreciated.

解决方案

Basically, the problem was I did not add rbenv/bin/rbenv to $PATH.

export PATH="$HOME/.rbenv/bin:$PATH"

Better yet, add this to your .bashrc or .bash_profile to start every session with rbenv.

After that, make sure to:

eval "$(rbenv init -)"

In order to enable shims and autocompletion.

fishshell

For those using fish, you can accomplish the same like this:

if status --is-interactive
  . (rbenv init - | psub)
end

Now, if you don't like modifying $PATH directly and have ownership over /usr/local/bin, a more nifty solution is to symlink with ~/.rbenv/bin/rbenv.

 ln -s ~/.rbenv/bin/rbenv /usr/local/bin

ruby-build

As a final warning, make sure to install ruby-build (a rbenv plugin to add the install command to rbenv and be able to easily install Ruby versions.)

If you are using homebrew it's easy as pie:

brew install ruby-build

这篇关于如何使用rbenv在没有sudo的情况下全局安装gem?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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