无法使用`sudo`安装gems

发布于 2024-09-18 00:54:08 字数 880 浏览 5 评论 0原文

我刚刚安装了一台新的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

通知家属抬走 2024-09-25 00:54:08

当您不使用 sudo 时,rubygems 会在您的主目录中查找 .gemrc 文件。当你使用 sudo 时,我认为在 Ubuntu 下它找不到你的 .gemrc 并使用“sources”文件(对我来说,它位于 /var/lib/gems/1.8/gems/sources-0.0.1/lib 中) 。尝试将 ruby​​gems 源更新为 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.

霞映澄塘 2024-09-25 00:54:08

尝试将以下内容放入 /etc/gemrc 中:

---
:sources:
- http://rubygems.org
:update_sources: true
:benchmark: false
:bulk_threshold: 1000
:backtrace: false
:verbose: true

Try to put following content in /etc/gemrc:

---
:sources:
- http://rubygems.org
:update_sources: true
:benchmark: false
:bulk_threshold: 1000
:backtrace: false
:verbose: true
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文