如何让RVM在Ubuntu 16.04上为本地用户工作?

时间:2016-08-04 00:01:03

标签: ruby ubuntu rubygems rvm

我正在运行ubuntu 16.04桌面,并尝试让RVM正常工作以便我可以:

  • 安装并使用最新稳定版本的ruby。
  • 在没有SUDO权限的情况下,在必要时安装Ruby gem。

为此,这就是我所做的:

按照官方RVM网站上的说明安装RVM:https://rvm.io/

# This keyserver can't be found, btw. So this bit doesn't work.
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

gpg: requesting key D39DC0E3 from hkp server keys.gnupg.net
?: keys.gnupg.net: Host not found
gpgkeys: HTTP fetch error 7: couldn't connect: Success
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
gpg: keyserver communications error: keyserver unreachable
gpg: keyserver communications error: public key not found
gpg: keyserver receive failed: public key not found

# Install RVM w/ ruby.
$ \curl -sSL https://get.rvm.io | bash -s stable --ruby

Downloading https://github.com/rvm/rvm/archive/1.27.0.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc
gpg: Signature made Tue 29 Mar 2016 06:49:47 AM PDT using RSA key ID BF04FF17
gpg: Good signature from "Michal Papis (RVM signing) <mpapis@gmail.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 409B 6B17 96C2 7546 2A17  0311 3804 BB82 D39D C0E3
     Subkey fingerprint: 62C9 E5F4 DA30 0D94 AC36  166B E206 C29F BF04 FF17
GPG verified '/home/rdegges/.rvm/archives/rvm-1.27.0.tgz'

Upgrading the RVM installation in /home/rdegges/.rvm/
    RVM PATH line found in /home/rdegges/.zshrc.
    RVM PATH line not found for Bash, rerun this command with '--auto-dotfiles' flag to fix it.
    RVM sourcing line found in /home/rdegges/.zshrc.
    RVM sourcing line not found for Bash, rerun this command with '--auto-dotfiles' flag to fix it.
Upgrade of RVM in /home/rdegges/.rvm/ is complete.

# Randall Degges,
#
#   Thank you for using RVM!
#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.

In case of problems: https://rvm.io/help and https://twitter.com/rvm_io

Upgrade Notes:

  * No new notes to display.

rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
Already installed ruby-2.3.0.
To reinstall use:

    rvm reinstall ruby-2.3.0

Creating alias default for ruby-2.3.0....

  * To start using RVM you need to run `source /home/rdegges/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

此时,即使无法导入GPG密钥,我也能够成功安装RVM / Ruby。

我通过在~/.zshrc文件中包含以下代码段来获取RVM文件:

PATH=$PATH:$HOME/.rvm/bin
[[ -s "~/.rvm/scripts/rvm" ]] && source "~/.rvm/scripts/rvm"

这很有效,我可以通过回复我的$ PATH来证实这一点,例如:

$ echo $PATH
...:/home/rdegges/.rvm/bin

最后,如果我使用rvm输出已安装的ruby版本列表,我看到安装了ruby:

$ rvm list
rvm rubies

=* ruby-2.3.0 [ x86_64 ]

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

这使我看起来好像我安装了ruby 2.3.0并默认。

在这里,事情变得奇怪......

如果我说which ruby,我会:

$ which ruby
/usr/bin/ruby

我希望看到我的ruby版本来自~/.rvm

其次,当我尝试安装任何gem时,例如:travis,我收到以下权限错误:

$ gem install travis
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.3.0 directory.

显然,这不是事情本应该起作用的方式。 RVM应该为我的用户本地安装ruby,以便我可以安装gem并使用不同版本的ruby而无需覆盖系统文件和包。

我一定做错了什么,但我花了几个小时搜索stackoverflow,官方rvm文档等等,并且找不到解决方案。

我做错了什么?

0 个答案:

没有答案