rubygems 更新破坏了 OSX 上的 ruby

发布于 2024-10-29 18:33:08 字数 1641 浏览 1 评论 0原文

我在运行一些 Ruby 脚本时遇到了一些问题。在尝试运行这些脚本时,我尝试了很多不同的方法以及更新 ruby​​gems,因为我认为这可能是问题所在。从那时起我就无法运行任何 Ruby 脚本了。

我认为如果我可以将 ruby​​gems 恢复到其原始版本,我也许可以再次运行 Ruby 脚本,但我不知道如何操作。

    $ gem environment
  RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.5
  - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-10
  - GEM PATHS:
     - /Library/Ruby/Gems/1.8
     - /Users/ryan/.gem/ruby/1.8
     - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/

    $ ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10]

    $ which -a ruby
/opt/local/bin/ruby
/opt/local/bin/ruby
/usr/bin/ruby
/usr/local/bin/ruby

    $ which -a gem
/usr/bin/gem
/usr/local/bin/gem

感谢您提前提供的任何帮助。

瑞安

$ ruby spidr_start_at.rb 
spidr_start_at.rb:1:in `require': no such file to load -- rubygems (LoadError)
    from spidr_start_at.rb:1

$ cat spidr_start_at.rb 
require 'rubygems'
require 'uri'
require 'spidr'

url = 'http://www.ethicalhack3r.co.uk'

puts "Spidr.start_at()"
puts

Spidr.start_at(url, :depth => 1) do |spider|

 spider.every_page do |page|
  puts page.url.to_s
 end

end

I was having some trouble running some Ruby scripts. While trying to get these scripts to run I tried lots of different things as well as updating rubygems as I thought this may be the problem. Since then I can't get any Ruby scripts to run.

I think that if I can revert rubygems back to it's original version I may be able to run Ruby scripts again, but I don't know how.

    $ gem environment
  RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.5
  - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-10
  - GEM PATHS:
     - /Library/Ruby/Gems/1.8
     - /Users/ryan/.gem/ruby/1.8
     - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/

    $ ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10]

    $ which -a ruby
/opt/local/bin/ruby
/opt/local/bin/ruby
/usr/bin/ruby
/usr/local/bin/ruby

    $ which -a gem
/usr/bin/gem
/usr/local/bin/gem

Thank you for any help in advance.

Ryan

$ ruby spidr_start_at.rb 
spidr_start_at.rb:1:in `require': no such file to load -- rubygems (LoadError)
    from spidr_start_at.rb:1

$ cat spidr_start_at.rb 
require 'rubygems'
require 'uri'
require 'spidr'

url = 'http://www.ethicalhack3r.co.uk'

puts "Spidr.start_at()"
puts

Spidr.start_at(url, :depth => 1) do |spider|

 spider.every_page do |page|
  puts page.url.to_s
 end

end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

眼睛会笑 2024-11-05 18:33:08

您似乎安装了多个版本的 ruby​​(和 gem)。维护多个 ruby​​ 版本时建议使用rvm。或者清理错误/旧的/不需要的安装。

It seems that you have multiple versions of ruby(and gem) installed. It is advised to use rvm when maintaining multiple ruby versions. Or clean up your wrong/old/unneeded installations.

成熟稳重的好男人 2024-11-05 18:33:08

要降级 Rubygems,您可以执行以下操作:

sudo gem update --system VERSION

显然您必须在那里放置一个真实版本。

For downgrading Rubygems, you can do the following:

sudo gem update --system VERSION

You obviously have to put a real version there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文