Ubuntu下的rvm ruby​​ gems(未能)安装在错误的位置 [英] ruby gems under rvm on Ubuntu (failing to) install in the wrong location

查看:109
本文介绍了Ubuntu下的rvm ruby​​ gems(未能)安装在错误的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行的是Ubuntu 10.04,最初安装了ruby 1.9.1(来自源代码)。我刚刚决定尝试使用ruby 1.9.2和rails 3,现在似乎是使用rvm处理多个ruby安装和gemset的好时机。



rvm已安装并似乎工作,我在rvm中安装了ruby 1.9.2,并将其作为我的默认ruby。然而,每次我尝试在ruby 1.9.2下安装一个gem时,我都会看到这个错误。

  mark @ Steve-Austins-企鹅:〜$ gem install haml 
错误:执行gem时(Errno :: EACCES)
权限被拒绝 - /home/mark/.gem/specs

gem environment 返回:

  RubyGems环境:
- RUBYGEMS版本:1.3.7
- RUBY VERSION:1.9.2(2010-08-18 patchlevel 0)[x86_64-linux]
- 安装目录:/home/mark/.rvm/gems/ruby-1.9.2-p0
- RUBY EXECUTABLE:/home/mark/.rvm/rubies/ruby-1.9.2-p0 / bin / ruby​​
- EXECUTABLE DIRECTORY:/home/mark/.rvm/gems/ruby-1.9.2-p0/bin
- RUBYGEMS平台:
- ruby​​
- x86_64-linux
- 创业板路径:
- /home/mark/.rvm/gems/ruby-1.9.2-p0
- /home/mark/.rvm/gems/ruby- 1.9.2-p0@global
< snip>

但是,如果正确的安装,ruby和gem路径显示在这里,为什么ruby试图安装gems /home/mark/.gem ?所有由 env 显示的变量和路径看起来都是正确的,而且我找不到任何位于我的任何位置的 .gemrc 文件系统可能包含冲突的路径设置。



所以我想我的问题是可能导致rubygems尝试安装到 / home / mark / .gems 代替rvm设置的正确路径?






回应以下问题:

  mark @ Steve-Austins-Penguin:〜$ echo $ PATH 
/home/mark/.rvm/宝石/红宝石1.9.2-P0 /斌:/home/mark/.rvm/gems/ruby-1.9.2-p0@global/bin:/home/mark/.rvm/rubies/ruby-1.9.2- p0 / bin:/home/mark/.rvm/bin:/ usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin:/ usr / games
mark @ Steve-Austins-Penguin:〜$ $ gem
/home/mark/.rvm/rubies/ruby-1.9.2-p0/bin/gem
mark @ Steve-Austins-Penguin :〜$ rvm list

rvm rubies

ruby​​-1.8.7-p302 [x86_64]
=> ruby-1.9.2-p0 [x86_64]

mark @ Steve-Austins-Penguin:〜$ env
rvm_gemsets_path = / home / mark / .rvm / gemsets
MANPATH = :/home/mark/.rvm/man
rvm_scripts_path = / home / mark / .rvm / scripts
rvm_bin_path = / home / mark / .rvm / bin
GEM_HOME = / home / mark /.rvm/gems/ruby-1.9.2-p0
rvm_patchsets_path = / home / mark / .rvm / patchsets
SHELL = / bin / bash
IRBRC = / home / mark /。 rvm / rubies / ruby​​-1.9.2-p0 / .irbrc
rvm_patches_path = / home / mark / .rvm / patches
MY_RUBY_HOME = / home / mark / .rvm / rubies / ruby​​-1.9.2 -p0
rvm_selfcontained = 1
USER =标记
__shell_array_start = 0
rvm_gems_cache_path = / home / mark / .rvm / gems / cache
rvm_config_path = / home / mark /.rvm/config
rvm_path = / home / mark / .rvm
USERNAME = mark
rvm_gemset_separator = @
rvm_ruby_args =
rvm_rubies_path = / home / mark /。 rvm / rubies
PWD = / home / mark
rvm_hooks_path = / home / mark / .rvm / hooks
rvm_version = 1.0.1
rvm_src_path = / home / mark / .rvm / src
HOME = / home / mark
rvm_gems_path = / home / mark / .rvm / gems
rvm_ruby_string = ruby​​-1.9.2-p0
BUNDLE_PATH = / home / mark / .rvm / gems / ruby​​-1.9.2-p0
rvm_tmp_path = / home / mark / .rvm / tmp
LOGNAME = mark
GEM_PATH = / home / mark / .rvm / gems / ruby​​-1.9.2-p0:/home/mark/.rvm/gems/ruby-1.9.2-p0@global
rvm_action = list
rvm_log_path = / home / mark / .rvm / log
rvm_interactive = 1
RUBY_VERSION = ruby​​-1.9.2-p0
rvm_archives_path = / home / mark / .rvm / archives
rvm_repo_path = / home / mark / .rvm / repos
_ = / usr / bin / env

请注意,我从 env 稍微编辑了一下 - 仅仅是为了保持这篇文章的大小受到控制 - 通过删除所有与X,GNOME和SSH相关的条目。 继续从安装-V --backtrace --debug haml (感谢zzzhc)并仔细查看 /home/mark/.gem 目录I发现那里没有安装宝石,只是gemspec文件和宝石源文件。本着试验的精神,我删除了 /home/mark/.gem 并重新运行了 gem install 命令,并突然它正在工作。并且它为我刚刚安装的宝石重新创建了 /home/mark/.gem ,其中包含gemspecs。



现在很明显,我错误地解释了原始问题中的错误信息; rubygems在尝试将gem安装到 /home/mark/.gem 时没有失败,它只是将该目录用作临时存储新近下载的gems的gemspec被安装。在安装rvm之前,我一直使用 sudo gem install ... 将gems安装到系统上,这会创建 /home/mark/.gem 具有根权限的目录。因此, ruby​​gems 运行时没有 sudo 无法访问临时目录来存储gemspecs并且在安装宝石。 Doh!

I'm running Ubuntu 10.04 and originally installed ruby 1.9.1 (from source). I've just decided to try out ruby 1.9.2 and rails 3, and it seemed like a good time to use rvm to deal with the multiple ruby installs and gemsets.

rvm installed and seems to be working, I installed ruby 1.9.2 in rvm and made that my default ruby. However, every time I try to install a gem under ruby 1.9.2 I see this error.

mark@Steve-Austins-Penguin:~$ gem install haml  
ERROR:  While executing gem ... (Errno::EACCES)  
Permission denied - /home/mark/.gem/specs

gem environment returns:

RubyGems Environment:  
- RUBYGEMS VERSION: 1.3.7  
- RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [x86_64-linux]  
- INSTALLATION DIRECTORY: /home/mark/.rvm/gems/ruby-1.9.2-p0  
- RUBY EXECUTABLE: /home/mark/.rvm/rubies/ruby-1.9.2-p0/bin/ruby  
- EXECUTABLE DIRECTORY: /home/mark/.rvm/gems/ruby-1.9.2-p0/bin  
- RUBYGEMS PLATFORMS:  
- ruby  
- x86_64-linux  
- GEM PATHS:  
 - /home/mark/.rvm/gems/ruby-1.9.2-p0  
 - /home/mark/.rvm/gems/ruby-1.9.2-p0@global  
<snip>

But if the correct installation, ruby and gem paths are showing here why is ruby trying to install gems to /home/mark/.gem? All the variables and paths shown by env look right, and I can't find a .gemrc file anywhere on my system that might contain conflicting path settings.

So I guess my question is what might be causing rubygems to attempt to install to /home/mark/.gems instead of the correct paths set by rvm?


In response to the question below:

mark@Steve-Austins-Penguin:~$ echo $PATH
/home/mark/.rvm/gems/ruby-1.9.2-p0/bin:/home/mark/.rvm/gems/ruby-1.9.2-p0@global/bin:/home/mark/.rvm/rubies/ruby-1.9.2-p0/bin:/home/mark/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games  
mark@Steve-Austins-Penguin:~$ which gem
/home/mark/.rvm/rubies/ruby-1.9.2-p0/bin/gem
mark@Steve-Austins-Penguin:~$ rvm list

rvm rubies

   ruby-1.8.7-p302 [ x86_64 ]
=> ruby-1.9.2-p0 [ x86_64 ]

mark@Steve-Austins-Penguin:~$ env
rvm_gemsets_path=/home/mark/.rvm/gemsets
MANPATH=:/home/mark/.rvm/man
rvm_scripts_path=/home/mark/.rvm/scripts
rvm_bin_path=/home/mark/.rvm/bin
GEM_HOME=/home/mark/.rvm/gems/ruby-1.9.2-p0
rvm_patchsets_path=/home/mark/.rvm/patchsets
SHELL=/bin/bash
IRBRC=/home/mark/.rvm/rubies/ruby-1.9.2-p0/.irbrc
rvm_patches_path=/home/mark/.rvm/patches
MY_RUBY_HOME=/home/mark/.rvm/rubies/ruby-1.9.2-p0
rvm_selfcontained=1
USER=mark
__shell_array_start=0
rvm_gems_cache_path=/home/mark/.rvm/gems/cache
rvm_config_path=/home/mark/.rvm/config
rvm_path=/home/mark/.rvm
USERNAME=mark
rvm_gemset_separator=@
rvm_ruby_args=
rvm_rubies_path=/home/mark/.rvm/rubies
PWD=/home/mark
rvm_hooks_path=/home/mark/.rvm/hooks
rvm_version=1.0.1
rvm_src_path=/home/mark/.rvm/src
HOME=/home/mark
rvm_gems_path=/home/mark/.rvm/gems
rvm_ruby_string=ruby-1.9.2-p0
BUNDLE_PATH=/home/mark/.rvm/gems/ruby-1.9.2-p0
rvm_tmp_path=/home/mark/.rvm/tmp
LOGNAME=mark
GEM_PATH=/home/mark/.rvm/gems/ruby-1.9.2-p0:/home/mark/.rvm/gems/ruby-1.9.2-p0@global
rvm_action=list
rvm_log_path=/home/mark/.rvm/log
rvm_interactive=1
RUBY_VERSION=ruby-1.9.2-p0
rvm_archives_path=/home/mark/.rvm/archives
rvm_repo_path=/home/mark/.rvm/repos
_=/usr/bin/env

Note that I've edited down the response from env slightly - simply to keep the size of this post under control - by removing all the entries relating to X, GNOME and SSH.

解决方案

Following up the backtrace from running gem install -V --backtrace --debug haml (thanks zzzhc) and taking a closer look at the /home/mark/.gem directory I found that there were no gems installed there, just gemspec files and gem source files. In the spirit of experimentation I deleted /home/mark/.gem and re ran the gem install command and suddenly it was working. And that it had recreated /home/mark/.gem containing gemspecs for the gems I'd just installed.

It's clear now that I'd misinterpreted the error message in the original question; rubygems didn't fail while trying to install gems to /home/mark/.gem, it was simply using that directory as a temporary store for the gemspecs of newly downloaded gems about to be installed. Before installing rvm I'd been installing gems onto the system using sudo gem install... which would have created the /home/mark/.gem directory with root permissions. So rubygems run without sudo was unable to access the temp directory to store gemspecs in and was aborting before it could install the gems. Doh!

这篇关于Ubuntu下的rvm ruby​​ gems(未能)安装在错误的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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