rvm 系统安装,bin 没有正确符号链接 [英] rvm system install, bins not properly symlinked

查看:49
本文介绍了rvm 系统安装,bin 没有正确符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ubuntu 12.04 上安装了 rvm 系统:
$ \curl -L https://get.rvm.io |sudo bash -s 稳定

到目前为止,我一直执行单用户安装,老实说,我对系统范围安装的结果感到很困惑.
它确实将 rvm bin 目录放在我的路径中,但它用不能直接使用的名称符号链接了所有二进制文件.
这是否意味着我应该将它们一一符号链接?
有什么问题吗?
这是默认行为吗?

appusr@server-name:/usr/local/rvm/bin$ ll共 60 个drwxrwsr-x 2 根 rvm 4096 4 月 5 日 13:11./drwxrwsr-x 23 根 rvm 4096 4 月 5 日 13:04 ../-rwxrwxr-x 1 根 rvm 578 Apr 5 13:04 bundle*lrwxrwxrwx 1 appusr rvm 41 Apr 5 13:11 erb-ruby-2.0.0-p0 ->/usr/local/rvm/wrappers/ruby-2.0.0-p0/erb*lrwxrwxrwx 1 appusr rvm 48 Apr 5 13:11 erb-ruby-2.0.0-p0@global ->/usr/local/rvm/wrappers/ruby-2.0.0-p0@global/erb*lrwxrwxrwx 1 appusr rvm 41 Apr 5 13:11 gem-ruby-2.0.0-p0 ->/usr/local/rvm/wrappers/ruby-2.0.0-p0/gem*lrwxrwxrwx 1 appusr rvm 48 Apr 5 13:11 gem-ruby-2.0.0-p0@global ->/usr/local/rvm/wrappers/ruby-2.0.0-p0@global/gem*lrwxrwxrwx 1 appusr rvm 41 Apr 5 13:11 irb-ruby-2.0.0-p0 ->/usr/local/rvm/wrappers/ruby-2.0.0-p0/irb*lrwxrwxrwx 1 appusr rvm 48 Apr 5 13:11 irb-ruby-2.0.0-p0@global ->/usr/local/rvm/wrappers/ruby-2.0.0-p0@global/irb*-rwxrwxr-x 1 根 rvm 556 4 月 5 日 13:04 耙*lrwxrwxrwx 1 appusr rvm 42 Apr 5 13:11 rake-ruby-2.0.0-p0 ->/usr/local/rvm/wrappers/ruby-2.0.0-p0/rake*lrwxrwxrwx 1 appusr rvm 49 Apr 5 13:11 rake-ruby-2.0.0-p0@global ->/usr/local/rvm/wrappers/ruby-2.0.0-p0@global/rake*lrwxrwxrwx 1 appusr rvm 42 Apr 5 13:11 rdoc-ruby-2.0.0-p0 ->/usr/local/rvm/wrappers/ruby-2.0.0-p0/rdoc*lrwxrwxrwx 1 appusr rvm 49 Apr 5 13:11 rdoc-ruby-2.0.0-p0@global ->/usr/local/rvm/wrappers/ruby-2.0.0-p0@global/rdoc*lrwxrwxrwx 1 appusr rvm 40 Apr 5 13:11 ri-ruby-2.0.0-p0 ->/usr/local/rvm/wrappers/ruby-2.0.0-p0/ri*lrwxrwxrwx 1 appusr rvm 47 Apr 5 13:11 ri-ruby-2.0.0-p0@global ->/usr/local/rvm/wrappers/ruby-2.0.0-p0@global/ri*lrwxrwxrwx 1 appusr rvm 42 Apr 5 13:11 ruby​​-2.0.0-p0 ->/usr/local/rvm/wrappers/ruby-2.0.0-p0/ruby*lrwxrwxrwx 1 appusr rvm 49 Apr 5 13:11 ruby​​-2.0.0-p0@global ->/usr/local/rvm/wrappers/ruby-2.0.0-p0@global/ruby*-rwxrwxr-x 1 根 rvm 1307 Apr 5 13:04 rvm*-rwxrwxr-x 1 根 rvm 1512 Apr 5 13:04 rvm-auto-ruby*-rwxrwxr-x 1 根 rvm 1803 年 4 月 5 日 13:04 rvm-exec*-rwxrwxr-x 1 根 rvm 13130 Apr 5 13:04 rvm-installer*-rwxrwxr-x 1 根 rvm 3850 Apr 5 13:04 rvm-prompt*-rwxrwxr-x 1 根 rvm 2263 4 月 5 日 13:04 rvm-shell*-rwxrwxr-x 1 根 rvm 648 Apr 5 13:04 rvm-smile*-rwxrwxr-x 1 根 rvm 2229 Apr 5 13:04 rvmsudo*lrwxrwxrwx 1 appusr rvm 44 Apr 5 13:11 testrb-ruby-2.0.0-p0 ->/usr/local/rvm/wrappers/ruby-2.0.0-p0/testrb*lrwxrwxrwx 1 appusr rvm 51 Apr 5 13:11 testrb-ruby-2.0.0-p0@global ->/usr/local/rvm/wrappers/ruby-2.0.0-p0@global/testrb*appusr@server-name:/usr/local/rvm/bin$appusr@server-name:/usr/local/rvm/bin$appusr@server-name:/usr/local/rvm/bin$appusr@server-name:/usr/local/rvm/bin$ 哪个 rubyappusr@server-name:/usr/local/rvm/bin$ 哪个 irbappusr@server-name:/usr/local/rvm/bin$ 哪个 gemappusr@server-name:/usr/local/rvm/bin$/usr/bin/env ruby​​ -v/usr/bin/env: ruby​​: 没有那个文件或目录appusr@server-name:/usr/local/rvm/bin$ ruby​​ -v程序ruby"可以在以下软件包中找到:* 红宝石1.8* ruby​​1.9.1请您的管理员安装其中之一appusr@server-name:/usr/local/rvm/bin$

解决方案

我相信我找到了问题所在.显然 rvm 没有正确加载为函数,即
<代码>$ 类型 rvm |head -n 1
没有返回rvm 是一个函数",而是诸如rvm 被散列"之类的东西(...?...).

同样有趣的是,问题不仅限于系统范围的安装.我内爆了系统范围的 rvm 安装,删除了 /etc 中的引用,然后在没有 sudo 的情况下再次安装了它......同样的问题.>

我会说这是我的错,我的"是指我不知道 bash 如何处理一些用户切换.它可能对其他人也有用,所以我会报告我所做的.

我以普通用户的身份通过 ssh 进入服务器,然后切换到将运行 rails 堆栈的用户:su appusr(使用 bash).

在那之后,我安装了 rvm 使用:
$ \curl -L https://get.rvm.io |bash -s 稳定

<小时>

当我尝试系统范围的安装时,我当然也将用户添加到 rvm 组:
$ sudo usermod -a -G rvm appusr

<小时>

...然后注销并再次登录:exit,然后再次su appusr.

现在,似乎这样做 bash 只是采购 ~/.bashrc,而不是 ~/.bash_profile rvm 有放置了将 rvm 作为函数加载的语句:
[[ -s "$HOME/.rvm/scripts/rvm" ]] &&源$HOME/.rvm/scripts/rvm"

尽管如此,rvm 二进制文件在我的 PATH 中,我可以发出安装 ruby​​ 所需的命令.
到目前为止,一切都很好.
问题是,在安装后,它以某种方式未能选择only ruby 作为默认解释器安装,因此它没有创建符号链接.

我注意到了,因为当我发布 rvm list 时,我看到了:

rvm rubiesruby-2.0.0-p0 [ x86_64 ]# =>- 当前的# =* - 当前 &&默认#  * - 默认

...注意它是如何NOT=*标记的.
我使用了命令 rvm use ruby​​-2.0.0-p0 --default,我被警告说 rvm 没有作为函数加载并且某些东西无法工作(无法记住确切的消息).

这是一个突破,当我找到 ~/.bash_profile 时,我可以成功地选择那个 ruby 和所有的符号链接(rubyirbrake 等)立即被创建.

不过,这并不理想.
我的 $HOME 文件夹的默认设置通常包含三个文件:~/.profile~/.bash_profile~/.bashrc(加上 zsh 的那些).
~/.bash_profile 是由 rvm 安装添加的,我有它的源代码 ~/.profile.
~/.profile,然后,如果正在使用 bash,则自动获取 ~/.bashrc.

然而,正如我所说,通过执行 su appusr bash 只是来源 ~/.bashrc,因此无法解析语句加载rvm 作为一个函数.很烦人.
告诉 ~/.bashrc~/.bash_profile 需要某种控制(一个 ENV 变量?)来避免无限引用循环,这似乎有点矫枉过正……
所以我只是移动了 [[ -s "$HOME/.rvm/scripts/rvm" ]] &&将$HOME/.rvm/scripts/rvm" 导入~/.bashrc,我想说现在一切似乎都正常了.

I'm on ubuntu 12.04 and installed rvm system wide with:
$ \curl -L https://get.rvm.io | sudo bash -s stable

So far I've always performed single user installs and to he honest I'm quite confused by the results of the system wide install.
It did put the rvm bin directory in my path, but it symlinked all the binaries with names that can't be directly used.
Does it mean that I should symlink them one by one?
Did something go wrong?
Is that the defalt behaviour?

appusr@server-name:/usr/local/rvm/bin$ ll
total 60
drwxrwsr-x  2 root     rvm   4096 Apr  5 13:11 ./
drwxrwsr-x 23 root     rvm   4096 Apr  5 13:04 ../
-rwxrwxr-x  1 root     rvm    578 Apr  5 13:04 bundle*
lrwxrwxrwx  1 appusr   rvm     41 Apr  5 13:11 erb-ruby-2.0.0-p0 -> /usr/local/rvm/wrappers/ruby-2.0.0-p0/erb*
lrwxrwxrwx  1 appusr   rvm     48 Apr  5 13:11 erb-ruby-2.0.0-p0@global -> /usr/local/rvm/wrappers/ruby-2.0.0-p0@global/erb*
lrwxrwxrwx  1 appusr   rvm     41 Apr  5 13:11 gem-ruby-2.0.0-p0 -> /usr/local/rvm/wrappers/ruby-2.0.0-p0/gem*
lrwxrwxrwx  1 appusr   rvm     48 Apr  5 13:11 gem-ruby-2.0.0-p0@global -> /usr/local/rvm/wrappers/ruby-2.0.0-p0@global/gem*
lrwxrwxrwx  1 appusr   rvm     41 Apr  5 13:11 irb-ruby-2.0.0-p0 -> /usr/local/rvm/wrappers/ruby-2.0.0-p0/irb*
lrwxrwxrwx  1 appusr   rvm     48 Apr  5 13:11 irb-ruby-2.0.0-p0@global -> /usr/local/rvm/wrappers/ruby-2.0.0-p0@global/irb*
-rwxrwxr-x  1 root     rvm    556 Apr  5 13:04 rake*
lrwxrwxrwx  1 appusr   rvm     42 Apr  5 13:11 rake-ruby-2.0.0-p0 -> /usr/local/rvm/wrappers/ruby-2.0.0-p0/rake*
lrwxrwxrwx  1 appusr   rvm     49 Apr  5 13:11 rake-ruby-2.0.0-p0@global -> /usr/local/rvm/wrappers/ruby-2.0.0-p0@global/rake*
lrwxrwxrwx  1 appusr   rvm     42 Apr  5 13:11 rdoc-ruby-2.0.0-p0 -> /usr/local/rvm/wrappers/ruby-2.0.0-p0/rdoc*
lrwxrwxrwx  1 appusr   rvm     49 Apr  5 13:11 rdoc-ruby-2.0.0-p0@global -> /usr/local/rvm/wrappers/ruby-2.0.0-p0@global/rdoc*
lrwxrwxrwx  1 appusr   rvm     40 Apr  5 13:11 ri-ruby-2.0.0-p0 -> /usr/local/rvm/wrappers/ruby-2.0.0-p0/ri*
lrwxrwxrwx  1 appusr   rvm     47 Apr  5 13:11 ri-ruby-2.0.0-p0@global -> /usr/local/rvm/wrappers/ruby-2.0.0-p0@global/ri*
lrwxrwxrwx  1 appusr   rvm     42 Apr  5 13:11 ruby-2.0.0-p0 -> /usr/local/rvm/wrappers/ruby-2.0.0-p0/ruby*
lrwxrwxrwx  1 appusr   rvm     49 Apr  5 13:11 ruby-2.0.0-p0@global -> /usr/local/rvm/wrappers/ruby-2.0.0-p0@global/ruby*
-rwxrwxr-x  1 root     rvm   1307 Apr  5 13:04 rvm*
-rwxrwxr-x  1 root     rvm   1512 Apr  5 13:04 rvm-auto-ruby*
-rwxrwxr-x  1 root     rvm   1803 Apr  5 13:04 rvm-exec*
-rwxrwxr-x  1 root     rvm  13130 Apr  5 13:04 rvm-installer*
-rwxrwxr-x  1 root     rvm   3850 Apr  5 13:04 rvm-prompt*
-rwxrwxr-x  1 root     rvm   2263 Apr  5 13:04 rvm-shell*
-rwxrwxr-x  1 root     rvm    648 Apr  5 13:04 rvm-smile*
-rwxrwxr-x  1 root     rvm   2229 Apr  5 13:04 rvmsudo*
lrwxrwxrwx  1 appusr   rvm     44 Apr  5 13:11 testrb-ruby-2.0.0-p0 -> /usr/local/rvm/wrappers/ruby-2.0.0-p0/testrb*
lrwxrwxrwx  1 appusr   rvm     51 Apr  5 13:11 testrb-ruby-2.0.0-p0@global -> /usr/local/rvm/wrappers/ruby-2.0.0-p0@global/testrb*
appusr@server-name:/usr/local/rvm/bin$ 
appusr@server-name:/usr/local/rvm/bin$ 
appusr@server-name:/usr/local/rvm/bin$ 
appusr@server-name:/usr/local/rvm/bin$ which ruby
appusr@server-name:/usr/local/rvm/bin$ which irb
appusr@server-name:/usr/local/rvm/bin$ which gem
appusr@server-name:/usr/local/rvm/bin$ /usr/bin/env ruby -v
/usr/bin/env: ruby: No such file or directory
appusr@server-name:/usr/local/rvm/bin$ ruby -v
The program 'ruby' can be found in the following packages:
 * ruby1.8
 * ruby1.9.1
Ask your administrator to install one of them
appusr@server-name:/usr/local/rvm/bin$

解决方案

I believe I found what was wrong. Apparently rvm wasn't properly loaded as a function, that is
$ type rvm | head -n 1
didn't return "rvm is a function", but something like "rvm is hashed" (...?...).

It is also interesting that the problem wasn't limited to the system wide install. I imploded the system wide rvm install, removed the references in /etc, and installed it again without sudo... same problem.

I'd say it was my fault, and by "my" I mean that I wasn't aware of how bash handles some user switches. It may be useful to others as well, so I'll report what I did.

I had ssh'd into the server as a general user and then switched to the user who will run the rails stack: su appusr (using bash).

After that, I installed rvm using:
$ \curl -L https://get.rvm.io | bash -s stable


When I tried the system wide install I of course also added the user to the rvm group with:
$ sudo usermod -a -G rvm appusr


...and logged out and in again: exit, and again su appusr.

Now, it seems that by doing so bash was only sourcing ~/.bashrc, and not ~/.bash_profile where rvm had placed the statement to load rvm as a function:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

Still, the rvm binary was in my PATH, and I could issue the commands needed to install ruby.
So far, so good.
The problem was that after the installation it somehow failed to select the only ruby I had installed as the default interpreter, and so it didn't create the symlinks.

I noticed it because when I issued rvm list I was presented with:

rvm rubies

   ruby-2.0.0-p0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

... notice how it was NOT marked with =*.
I used the command rvm use ruby-2.0.0-p0 --default, and I was warned that rvm wasn't loaded as a function and that something could not work (can't rememeber the exact message).

That was a breakthrough, and as I sourced ~/.bash_profile I could successfully select that ruby and all the symlinks (ruby, irb, rake, etc) were immediately created.

That wasn't ideal, though.
The default setup of my $HOME folder has the usual three files: ~/.profile, ~/.bash_profile and ~/.bashrc (plus the ones for zsh).
~/.bash_profile was added by the rvm installation, and I'm having it source ~/.profile.
~/.profile, then, automatically sources ~/.bashrc if bash is being used.

As I said, however, by doing su appusr bash just sources ~/.bashrc, and so fails to parse the statement loading rvm as a function. Very annoying.
Telling ~/.bashrc to source ~/.bash_profile would need some sort of control (an ENV variable?) to avoid an infinite reference loop, and seemed overkilling...
So I just moved [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" into ~/.bashrc, and I'd say everything seems to work now.

这篇关于rvm 系统安装,bin 没有正确符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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