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
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.
For downgrading Rubygems, you can do the following:
sudo gem update --system VERSION
You obviously have to put a real version there.
Related
I recently installed Ruby 2.0.0 on OS X 10.8.3 by compiling from source code. I checked the version with
$ ruby --version
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]
And I checked my gem version with
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.3
- RUBY VERSION: 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.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-12
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/ehartsuyker/.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
- :backtrace => false
- :bulk_threshold => 1000
- :benchmark => false
- :sources => ["http://rubygems.org/", "http://gemcutter.org"]
- REMOTE SOURCES:
- http://rubygems.org/
- http://gemcutter.org
I noticed that the reported version of Ruby here does not match the version I installed. I don't know if this matters or not.
I have a simple piece of code called encrypy.rb that I'm running. After installing the 'rsa' gem with gem install rsa.
require 'rubygems'
require 'rsa'
key = RSA::KeyPair.generate(128)
ciphertext = key.encrypt("message")
puts(ciphertext)
When I run it, it gives an error saying it can't find the gem.
$ ruby encrypt.rb -Idirectory '/Library/Ruby/Gems/1.8'
/usr/local/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- rsa (LoadError)
from /usr/local/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from encrypt.rb:2:in `<main>'
So the question is, why isn't Ruby finding the gem despite seeming to know where it is? And how can I fix it?
Ruby 1.8.7 is shipped with OS X. It seems that gem is seeing that version instead of your manually installed 2.0.0. As others already suggested, using RVM or rbenv (which one depends on personal preference) makes handling different ruby environments much easier. You can find those tools and descriptions for them in the following places:
RVM: https://rvm.io/
rbenv: https://github.com/sstephenson/rbenv
I am following this guide to install jekyll on OSX 10.7.3 and came up with the problem
ERROR: could not find gem jekyll locally or in a repository
I have tried:
sudo gem update --system (and get Nothing to update)
this post: How can I install Jekyll on Ubuntu 10.04 Server? , and it's no use.
I am not familiar with ruby and gem but I think this is needed:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.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-11
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/enzo/.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
- :sources => ["http://rubygems.org", "http://gems.github.com"]
- REMOTE SOURCES:
- http://rubygems.org
- http://gems.github.com
I don't know anything specifically about Jekyll, but there might very well be issues when running it with the system Ruby (that is, the one that comes with Mac OS).
Before wasting too much time bothering with the system Ruby (which could arguably be better left untouched), try to get either rbenv or rvm working. They allow you to install as many different versions of Ruby as you want without messing with the system Ruby, with each installation having its own gems.
Since you're not familiar with Ruby, I'll add that using rbenv or rvm is how most Ruby kids get their job done. Yes, it is an additional step that gets in the way, but it really does facilitate a smoother experience.
I recommend removing gems.github.com from your gem sources unless you really need it. GitHub ceased building gems from git repositories back in 2010. If you cannot remove it, then I recommend installing jekyll with the following command:
gem install --source http://rubygems.org jekyll
My rubygems environment for reference, as I'm on OS X 10.7.5.
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.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-11
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/matt/.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://rubygems.org/
I installed Jekyll directly into a new clean install of OSX Mavericks, and then wrote a quick post so I'd remember how to do it after I next reinstall my system. I've had plenty of feedback that others have had success following my guide, and no reports of anyone having any issues:
http://internet-inspired.com/wrote/install-jekyll-in-osx-mavericks/
I just migrated to a new Mac with OS X Lion. For some reson I can't install new Ruby gems anymore. Or rather: I can install them, but not find them.
This is my gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.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-11
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/Jens/.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://rubygems.org/
Running the gem crack in irb works fine:
>> require 'rubygems'
=> false
>> require 'crack'
=> true
But when I try to do the same in my text editor (Textwrangler) I run into this:
custom_require.rb:31: in `gem_original_require': no such file to load -- crack (LoadError)
Any suggestions?
Maybe a pointer in the right direction: I've had problems on Lion with different ruby versions being installed. Problem was that some programs calling ruby (in my case git for a pre-commit hook) had their $PATH variable different; as a result another version of ruby was found first (and that version didn't have the gems installed).
So to debug, try printing out the version of both rubys (rubies?), and the PATH variable (something like print RUBY_VERSION and print ENV["PATH"]; maybe also print ENV["GEM_HOME"]. See if that leads to anything.
FYI: for me the solution in the end was to upgrade from git 1.7.3 to 1.7.7; it wasn't clear to my why things didn't work in 1.7.3 (why the PATH was different), but who cares; it works again :))
I had Ruby 1.9.2 install, but I uninstalled it long ago. Today I installed a brand new version of Ruby 1.9.3, downloaded gem and set it up with ruby setup.rb.
I then noticed that installing gems failed, so I checked gem environment and this is what I get:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [i386-mingw32]
- INSTALLATION DIRECTORY: c:/Ruby192/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: C:/Ruby193/bin/ruby.exe
- EXECUTABLE DIRECTORY: c:/Ruby192/lib/ruby/gems/1.9.1/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- c:/Ruby192/lib/ruby/gems/1.9.1
- C:/.gem/ruby/1.9.1
- C:/Ruby193/lib/ruby/gems/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
It seems messing up the new installation (Ruby193) with the old one (Ruby192).
ruby -v yields, correctly, ruby 1.9.3p0 (2011-10-30) [i386-mingw32].
How to solve the problem?
EDIT: I had GEM_HOME and RUBYLIB environment variables set up to the old directories. Updating them solved the problem.
You shouldn't need to download gem or run ruby setup.rb.
I recommend removing all references to old rubies from your path environment variable and then downloading 1.9.3 from rubyinstaller.org install it and then download, install and run the devkit
I've installed the development version of Crunchbang, a linux distro based off Debian. I got Ruby and Rubygems installed, but I can't get the gems I've installed to load. Here is a command-line session:
$ ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i486-linux]
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.9.1 (2010-01-10 patchlevel 378) [i486-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby1.9.1/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby1.9.1/gems/1.9.1
- /home/corey/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
$ echo $PATH
/home/corey/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/home/corey/.gem/ruby/1.9.1:/usr/lib/ruby1.9.1/gems/1.9.1
$ gem list -d nokogiri
`*** LOCAL GEMS ***`
nokogiri (1.4.1)
Authors: Aaron Patterson, Mike Dalessio
Rubyforge: http://rubyforge.org/projects/nokogiri
Homepage: http://nokogiri.org
Installed at: /usr/lib/ruby1.9.1/gems/1.9.1
Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser
$ ruby -r rubygems -e "require 'nokogiri'"
-e:1:in `require': no such file to load -- nokogiri (LoadError)
from -e:1:in `'
I've encountered similar problems on Ubuntu before, but they were easy to fix. I can't figure out what's wrong in this particular case, and Google didn't seem to know either. Any help would be greatly appreciated!
By the way... this is my first submission to stackoverflow. I hope this question is relevant. :)
Debian does not load RubyGems by default. You can solve this by adding require 'rubygems' to your code or better still, have RubyGems loaded each time Ruby is run. I also run #! and achieved this by editing my ~/.profile adding export RUBYOPT=rubygems and finally reloading my profile with . ~/.profile.
For more information on this matter see: http://docs.rubygems.org/read/chapter/3
Is nokogiri in any of the directories in GEM PATHS?
I've had problems before with installing rubygems from the Debian repos and then installing in manually. Debian puts all gems in /var/ somewhere in the distribution package.