无法使用`sudo`安装gems
我刚刚安装了一台新的 Ubuntu 10.04 PC,并正在尝试安装一些 gem。
gerhard@superserver:~$ sudo gem install rake
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
ERROR: could not find gem rake locally or in a repository
gerhard@superserver:~$
我认为这是因为我的 HTTP_PROXY
设置不正确(我位于代理后面),但它是正确的。另外,gem 也可以在没有 sudo
的情况下正确安装。
gerhard@superserver:~$ gem install rake
WARNING: Installing to ~/.gem since /var/lib/gems/1.8 and
/var/lib/gems/1.8/bin aren't both writable.
WARNING: You don't have /home/gerhard/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
Successfully installed rake-0.8.7
1 gem installed
Installing ri documentation for rake-0.8.7...
Installing RDoc documentation for rake-0.8.7...
gerhard@superserver:~$
对于可能出现的问题或我应该查看哪些内容以找到此问题的可能原因有什么想法吗?
I have just setup a new Ubuntu 10.04 PC and am trying to install some gems.
gerhard@superserver:~$ sudo gem install rake
ERROR: http://gems.rubyforge.org/ does not appear to be a repository
ERROR: could not find gem rake locally or in a repository
gerhard@superserver:~$
I thought it was because my HTTP_PROXY
was set incorrectly (I am behind a proxy) but it is correct. Also the gem installs correctly without the sudo
gerhard@superserver:~$ gem install rake
WARNING: Installing to ~/.gem since /var/lib/gems/1.8 and
/var/lib/gems/1.8/bin aren't both writable.
WARNING: You don't have /home/gerhard/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
Successfully installed rake-0.8.7
1 gem installed
Installing ri documentation for rake-0.8.7...
Installing RDoc documentation for rake-0.8.7...
gerhard@superserver:~$
Any ideas as to what could be wrong or what I should look at to find possible causes for this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您不使用 sudo 时,rubygems 会在您的主目录中查找 .gemrc 文件。当你使用 sudo 时,我认为在 Ubuntu 下它找不到你的 .gemrc 并使用“sources”文件(对我来说,它位于 /var/lib/gems/1.8/gems/sources-0.0.1/lib 中) 。尝试将 rubygems 源更新为 http://rubygems.org。
如果这不起作用,请尝试安装 RVM。由于 RVM 安装 gem 时不需要 sudo,因此您不必担心。
When you are not using sudo, rubygems is finding your .gemrc file in your home directory. When you use sudo, I think under Ubuntu it doesn't find your .gemrc and uses the "sources" file instead (for me, it's in /var/lib/gems/1.8/gems/sources-0.0.1/lib). Try updating the rubygems source to http://rubygems.org.
If that doesn't work, try installing RVM. Since RVM installs gems without sudo, you won't have to worry about it.
尝试将以下内容放入
/etc/gemrc
中:Try to put following content in
/etc/gemrc
: