应该将rbenv安装在系统范围内还是用户级别? [英] Should rbenv be installed system-wide, or at a user level?

查看:113
本文介绍了应该将rbenv安装在系统范围内还是用户级别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建造一个流浪者设置,其中一部分是安装rbenv。我使用图书管理员厨师来管理我所有的厨师食谱,并安装了rbenv和ruby-build。然而,当我试图将ssh放入我的Vagrant VM时,键入 ruby​​ -v 我得到了标准的系统安装 ruby​​ 1.8.7(2012-02-08 patchlevel 358)[x86_64-linux] code>。考虑到可能没有安装rbenv,我尝试运行 rbenv版本,但实际上安装了rbenv:



<$ p $
$系统(由/ opt / rbenv / version设置)

vagrant @ precise64:〜$ rbenv版本
*

然后我尝试了 rbenv install [version]

  vagrant @ precise64:〜$ rbenv install 1.9.3-p327 
[...]

建立失败
[...]

test -z/opt/rbenv/versions/1.9.3-p327/include|| / bin / mkdir -p/opt/rbenv/versions/1.9.3-p327/include
/ bin / mkdir:无法创建目录`/opt/rbenv/versions/1.9.3-p327':Permission拒绝

Permission denied 失败。我试着用 sudo 重新安装:

  sudo rbenv install 1.9.3 -p327 

而且工作。然后,我再次尝试运行 rbenv版本

  vagrant @ precise64:〜 $ r 
$系统(由/ opt / rbenv / version设置)

仍然说只安装了 system ruby​​。然而,如果我用 sudo 运行它:

  vagrant @ precise64: 〜$ sudo rbenv版本
* system(由/home/vagrant/.rbenv/version设置)
1.9.3-p327

rbenv版本现在显示 1.9.3 已安装。 p>

因此,似乎有一个脱节,因为rbenv和我的ruby版本现在安装在系统级而不是用户级。



我正在使用 rbenv-cookbook 。我想让rbenv和厨师一起设置,因为这样可以避免我手动设置,安装后。



我遇到的另一个问题是它看起来像Rubyy控制的所有东西,比如 gem ,也都遭受同样的断开。

  vagrant @ precise64:〜$ gem install bundler 
获取:bundler-1.3.5.gem(100%)
错误:执行gem时...(Gem :: FilePermissionError )
您没有写入/opt/vagrant_ruby/lib/ruby/gems/1.8目录的权限。


解决方案

大约两年前,a 讨论发生在github上关于共享安装,这似乎回答了这个问题。



简介:sstephenson(rbenv作者)特别不喜欢鼓励系统范围的安装,因为权限,写访问等方面的复杂性。他认为增加强大的支持会使rbenv更复杂,更简单是我们的目标。



编辑

因为遇到fnichol的chef-rbenv cookbook,如果你真的想要安装一个系统范围的rbenv,给出一个正确和正确的方法,你可以自动与厨师(我推荐小刀独奏)。



它将它安装到 /etc/profile.d / ,所以它会为所有用户运行,将适当的ruby放入 PATH 中。


I'm building a vagrant setup, and part of that is installing rbenv. I'm using librarian-chef to manage all my chef cookbooks, and it installs rbenv and ruby-build.

However, when I tried to ssh into my Vagrant VM and type ruby -v I got the standard system-installed ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]. Thinking that maybe rbenv was not installed, I tried running rbenv versions, but rbenv was in fact installed:

vagrant@precise64:~$ rbenv versions
* system (set by /opt/rbenv/version)

So then I tried rbenv install [version]:

vagrant@precise64:~$ rbenv install 1.9.3-p327
[...]

BUILD FAILED
[...]

test -z "/opt/rbenv/versions/1.9.3-p327/include" || /bin/mkdir -p "/opt/rbenv/versions/1.9.3-p327/include"
/bin/mkdir: cannot create directory `/opt/rbenv/versions/1.9.3-p327': Permission denied

That failed with Permission denied. I tried installing again with sudo:

sudo rbenv install 1.9.3-p327

And that worked. Then I tried running rbenv versions again:

vagrant@precise64:~$ rbenv versions
* system (set by /opt/rbenv/version)

But it still says only system ruby is installed. However, if I run it with sudo:

vagrant@precise64:~$ sudo rbenv versions
* system (set by /home/vagrant/.rbenv/version)
  1.9.3-p327

rbenv versions now shows 1.9.3 was installed.

So there seems to be a disconnect, in that that rbenv and my ruby version are now installed on a system level and not on the user level.

I am using the rbenv-cookbook. I would like to have rbenv set up with chef, because that saves me from setting it up manually, post-install.

The other issue I'm having is that it seem like everything that is ruby-controlled, such as gem, is also suffering the same disconnect.

vagrant@precise64:~$ gem install bundler
Fetching: bundler-1.3.5.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /opt/vagrant_ruby/lib/ruby/gems/1.8 directory.

解决方案

About two years ago, a discussion happened in github about shared installs, which appears to answer the question.

Synopsis: sstephenson (rbenv author) specifically doesn't like encouraging system-wide installs because of complexities with permissions, write access, etc. He believes adding robust support would make rbenv more complex, and simplicity is the goal.

EDIT

I've since come across fnichol's chef-rbenv cookbook, which, if you actually want to install a system-wide rbenv, gives a right and proper method, and you can automate it with Chef (I recommend knife solo).

It installs this to /etc/profile.d/ so it will run for all users, putting the proper ruby into the PATH.

这篇关于应该将rbenv安装在系统范围内还是用户级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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