Gem Install Error: NameError - ruby

I havent been been able to install any Gem since I updated to Mac OSX Lion.
Every time I try to install any gem the terminal window hangs.
I've uninstalled everything including ruby and reinstalled Ruby Gems but that didn't solve the problem.
After running:
gem install rails --debug
I get this (only first lines shown):
Exception `NameError' at /opt/local/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:177 - uninitialized constant Gem::Commands::InstallCommand
Exception `LoadError' at /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36 - no such file to load -- psych
Exception `LoadError' at /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:62 - no such file to load -- psych
Exception `Errno::EEXIST' at /opt/local/lib/ruby/1.8/fileutils.rb:243 - File exists - /Users/marcogallen/.gem/specs/rubygems.org%80
Exception `Errno::EEXIST' at /opt/local/lib/ruby/1.8/fileutils.rb:243 - File exists - /Users/marcogallen/.gem/specs/gems.github.com%80
Exception `EOFError' at /opt/local/lib/ruby/1.8/net/protocol.rb:135 - end of file reached
Exception `EOFError' at /opt/local/lib/ruby/1.8/net/protocol.rb:120 - end of file reached
Exception `EOFError' at /opt/local/lib/ruby/1.8/net/http.rb:1060 - end of file reached
GEM env gives this:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.8
- RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11]
- INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /opt/local/bin/ruby
- EXECUTABLE DIRECTORY: /opt/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-11
- GEM PATHS:
- /opt/local/lib/ruby/gems/1.8
- /Users/[user]/.gem/ruby/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'm totally clueless here, I hope some one can give me a hint or something.
MAC Book PRO running OSX Lion
Thanks
Marco

Hey I had a really similar problem,
I upgraded to Ruby 1.9.2 using RVM Click here!
It has its own way of managing Gems for each instance of Ruby and helped me understand where the gems were kept etc... If you have a read you should get there!
If it doesn't help I am sorry, but might be worth a try!

Related

Sauce::Capybara::Driver uses a deprecated 'within_frame' method

It's seems like gem sauce-3.5.11 uses a deprecated 'within_frame' method.I have also tried to change to older version but I get the same error
undefined method `within_frame' for class `Sauce::Capybara::Driver' (NameError)
/Users/user/.rvm/gems/ruby-2.2.4/gems/sauce-3.5.11/lib/sauce/capybara.rb:41:in `'
/Users/user/.rvm/gems/ruby-2.2.4/gems/sauce-3.5.11/lib/sauce/capybara.rb:12:in `'
/Users/user/.rvm/gems/ruby-2.2.4/gems/sauce-3.5.11/lib/sauce/capybara.rb:11:in `'
/Users/user/.rvm/gems/ruby-2.2.4/gems/sauce-3.5.11/lib/sauce/capybara.rb:10:in `'
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.8
- RUBY VERSION: 2.2.4 (2015-12-16 patchlevel 230) [x86_64-darwin14.5.0]
- INSTALLATION DIRECTORY: /Users/user/.rvm/gems/ruby-2.2.4
- RUBY EXECUTABLE: /Users/user/.rvm/rubies/ruby-2.2.4/bin/ruby
- EXECUTABLE DIRECTORY: /Users/user/.rvm/gems/ruby-2.2.4/bin
- SPEC CACHE DIRECTORY: /Users/user/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/user/.rvm/rubies/ruby-2.2.4/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/user/.rvm/gems/ruby-2.2.4
- /Users/user/.rvm/gems/ruby-2.2.4#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/user/.rvm/gems/ruby-2.2.4/bin
- /Users/user/.rvm/gems/ruby-2.2.4#global/bin
- /Users/user/.rvm/rubies/ruby-2.2.4/bin
- /Users/user/.rvm/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/X11/bin
The sauce gem has not been upgraded to support the frames API change that occurred in the selenium driver (which the sauce driver derives from) in Capybara 2.8, and since the entire sauce gem is deprecated I would guess it's not going to be. You can either lock to capybara 2.7.1 or look further back in your stacktrace, figure out why the code is calling within_frame directly on the driver, and instead try calling it on the session like it should be.
page.driver.within_frame(...) # wrong
page.within_frame(...) # correct

uninitialized constant Timer::Timers

I am trying to do a task periodically, and I have seen this. I have installed the gem 'timer' using bundle install
and then here is my Timer class:
require 'timers'
class Timer
def initialize
timers = Timers::Group.new
timers.every(5) { puts "Another 5 seconds" }
end
end
but when i run the class i face with the error:
`require': cannot load such file -- timers (LoadError)
and here is the output of my gem env :
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.1
- RUBY VERSION: 2.3.0 (2015-12-25 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-2.3.0
- USER INSTALLATION DIRECTORY: /home/ubuntu/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-2.3.0/bin
- SPEC CACHE DIRECTORY: /home/ubuntu/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/rvm/gems/ruby-2.3.0
- /usr/local/rvm/gems/ruby-2.3.0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- "install" => "--no-rdoc --no-ri"
- "update" => "--no-rdoc --no-ri"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/ubuntu/.nvm/versions/node/v4.4.3/bin
- /usr/local/rvm/gems/ruby-2.3.0/bin
- /usr/local/rvm/gems/ruby-2.3.0#global/bin
- /usr/local/rvm/rubies/ruby-2.3.0/bin
- /mnt/shared/bin
- /home/ubuntu/workspace/node_modules/.bin
- /home/ubuntu/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /mnt/shared/sbin
- /opt/gitl
- /opt/go/bin
- /mnt/shared/c9/app.nw/bin
- /usr/local/rvm/bin
This error tells us the code you are trying to load is not on the LOAD_PATH. When you require 'timers' you are telling Ruby to search the LOAD_PATH for a file called timers.rb and it cannot be located. Installing the gem does not put the gem on your load path.
It sounds like you are not using Bundler to manage your dependencies. Once you start depending on 3rd party code, you really should start using Bundler. It will put all the code you need on the LOAD_PATH and provide a ton of other helpful features.
If you are just messing around, one option you can do is:
ruby -I <path/to/timers/lib>
This will allow Ruby to locate timers.rb

encrypted_strings (LoadError) received when running spotify ruby script

I am trying to run a Ruby script to setup a token exchange with spotify. I know nothing about Ruby, so am at a loss at how to resolve the following error in response to the following command:
ruby ./spotify_token_swap.rb
/Users/jeff/.rvm/rubies/ruby-2.1.5-dev/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- encrypted_strings (LoadError)
from /Users/jeff/.rvm/rubies/ruby-2.1.5-dev/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from ./spotify_token_swap.rb:6:in `<main>'
Line 54 of kernel_require.rb is:
return gem_original_require(path)
If it helps, here is my RubyGems environment:
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5
- RUBY VERSION: 2.1.5 (2014-11-13 patchlevel 273) [x86_64-darwin14.0]
- INSTALLATION DIRECTORY: /Users/jeff/.rvm/gems/ruby-2.1.5-dev
- RUBY EXECUTABLE: /Users/jeff/.rvm/rubies/ruby-2.1.5-dev/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jeff/.rvm/gems/ruby-2.1.5-dev/bin
- SPEC CACHE DIRECTORY: /Users/jeff/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/jeff/.rvm/gems/ruby-2.1.5-dev
- /Users/jeff/.rvm/gems/ruby-2.1.5-dev#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/jeff/.rvm/gems/ruby-2.1.5-dev/bin
- /Users/jeff/.rvm/gems/ruby-2.1.5-dev#global/bin
- /Users/jeff/.rvm/rubies/ruby-2.1.5-dev/bin
- /Users/jeff/.rvm/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/ImageMagick/bin
I am guessing that there is either a missing gem, or a problem with my path. But I really don't know. Can someone provide some handholding on how to resolve this problem?
Good debugging idea, but you went a bit too deep :) You don't need to know how Kernel.require works, just that
If the file named cannot be found, a LoadError will be raised.
You probably just need to install the encrypted_strings gem.

Textmate + RVM + Rake = Rake not using expected gem environment

I am using:
TextMate: version 2.0-alpha.9511
rvm: 1.25.15 (stable)
ruby: version 2.1.0p0
oh-my-zshell: 5.0.2
Mac OS X: 10.9.1 (Mavericks)
I have rvm and textmate set up to use
TM_RUBY=/Users/<myuser>/.rvm/bin/rvm-auto-ruby
The problem:
when I try to run my rake tasks using the rake bundle in textmate, I get some errors about the file not loading: "cannot load such file -- rubocop/rake_task"
The clue:
I changed my rakefile so that it simply reports the "gem env" for the default task.
When I then run the task, I see a completely different gem environment, than I would see if I used rake at the terminal command line.
RakeMate v2.0.0
>>> /Users/Johno/Projects/puzzles/triangle/Rakefile
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.3
- RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [universal.x86_64-darwin13]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-13
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/Johno/.gem/ruby/2.0.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
Whereas I see this when running
$ gem env
in my terminal, for my project
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.0.rc.1
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin12.0]
- INSTALLATION DIRECTORY: /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles
- RUBY EXECUTABLE: /Users/Johno/.rvm/rubies/ruby-2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles/bin
- SPEC CACHE DIRECTORY: /Users/Johno/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles
- /Users/Johno/.rvm/gems/ruby-2.1.0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles/bin
- /Users/Johno/.rvm/gems/ruby-2.1.0#global/bin
- /Users/Johno/.rvm/rubies/ruby-2.1.0/bin
- /Users/Johno/.rvm/bin
- /usr/local/bin
- /Users/Johno/Projects/Scripts/Ruby
- /Users/Johno/Projects/Scripts/bash
- /Users/Johno/Projects/Scripts/perl
- /Users/Johno/Projects/Scripts/Geek Tool
- /usr/bin
- /bin
I suspect that textmate is trying to use the "wrong" rake, or failing to set up the environment properly.
I think the problem may lie in the ruby bundle command from text mate:
#!/usr/bin/env bash
export RUBYLIB="$TM_BUNDLE_SUPPORT/RakeMate${RUBYLIB:+:$RUBYLIB}"
export TM_RAKE=$(which "${TM_RAKE:-rake}")
"/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby" -- "$TM_BUNDLE_SUPPORT/RakeMate/rake_mate.rb"
It appears to be using a specific ruby (1.8) rather than the rvm project specific ruby
Does anyone have a suggestion as to how to resolve this?
Thank you,
John Schank
Followed the advice to set TM_RAKE and it didn't help.
I tried both the suggested setting, and using the results of which rake
/Users/Johno/.rvm/gems/ruby-2.1.0#puzzles/bin/rake
When using my TM_RAKE, is get a different error
RakeMate v2.0.0
>>> /Users/Johno/Projects/puzzles/triangle/Rakefile
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'rake' (>= 0) among 5 total gem(s) (Gem::LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles/bin/rake:22:in `<main>'
This happens to be the same error I get when I try to use the rubocop.tmbundle
It still looks to me like the gem environment is not being passed to the child process.
I solved my own problem.
Here are the details for anyone else who has this problem...
First, the answer in this question TextMate, rvm and TM_RUBY
is almost perfect.
I had to create a textmate_ruby, and a textmate_rake script, and reference them in the variables in text mate: TM_RUBY, and TM_RAKE.
Second, since I'm using zsh, I had to change the shebang line in the textmate_xxx scripts to use zsh.
Finally, the key that helped me arrive at the correct solution is that I modified my project rakefile to :
task :default do
system "gem env"
system "ruby --version"
system "pwd"
system "printenv"
end
Then when I ran the rake task in textmate, it would dump the current values of my environment, ruby version, current directory, and gem environment. This really helped to see what was going on.
It seems that TextMate is still using your system rake instead of rvm's.
Try to set TM_RAKE in addition to TM_RUBY:
TM_RAKE=$HOME/.rvm/bin/rake
This also applies to rbenv, where you would set TM_RAKE to $HOME/.rbenv/shims/rake.

Ruby gem LoadError - rubygems/defaults/operating_system

I've installed ruby 1.8.6 p368 and gems 1.3.4 as well as required libraries like zlib, ssl or readline on my winxp sp3 box.
The problem is, when I now try to use some gem, I get the following error:
Exception `LoadError' at D:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:1112 - no su
ch file to load -- rubygems/defaults/operating_system
Exception `LoadError' at D:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.
rb:31 - no such file to load -- mysql
Seems like it makes sense to start with fixing the missing "rubygems/defaults/operating_system" file. How can I do that? TIA
PS:
gem env is
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.4
- RUBY VERSION: 1.8.6 (2009-03-31 patchlevel 368) [i386-mswin32]
- INSTALLATION DIRECTORY: D:/ruby/lib/ruby/gems/1.8
- RUBY EXECUTABLE: D:/ruby/bin/ruby.exe
- EXECUTABLE DIRECTORY: D:/ruby/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mswin32-60
- GEM PATHS:
- D:/ruby/lib/ruby/gems/1.8
- C:/Documents and Settings/fluffy/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://gems.rubyforge.org/
Were you running using -d? If so, this email reckons that it's displaying exceptions even when they're rescued.
It looks like you need the mysql gem too.
The following error
Exception 'LoadError' at D:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:1112 - no such file to load -- rubygems/defaults/operating_system
Can relate to either
a corrupt installation (check the rubygems.rb file and make sure it requires 'rubygems/defaults/operating_system'. If it does, check to see if it exists) or
you're trying to run a 2.3.x app while the server is still configured to using Rails 2.1.x
I hope this helps. If not, let me know.
Have you tried InstantRails? It has rails/apache/mysql in a nice package and worked out of the box on every XP box I tried.
I also install NetBeans as dev environment and just point it to InstantRails "bin/ruby" binary.

Resources