Gems not working (Windows 184-20)

P

Phrogz

I hate that I don't understand why this is failing, and have to turn to
the list for help.

The problem is that rubygems can't find files that it itself installed.

In an attempt to fix things, I just deleted my entire c:\ruby
directory, deleted all ruby-related environment variables, and re-ran
the 184-20 one-click installer. No help.

See the following session:

C:\Documents and Settings\gavin.kistner>gem -v
0.9.0

C:\Documents and Settings\gavin.kistner>gem install usage
Bulk updating Gem source index for: http://gems.rubyforge.org
Install required dependency SimpleTrace? [Yn]
Successfully installed usage-0.0.4
Successfully installed SimpleTrace-0.0.1

C:\Documents and Settings\gavin.kistner>gem list Usage

*** LOCAL GEMS ***

usage (0.0.4)
This module implements a simple no thought command line option
parser

C:\Documents and Settings\gavin.kistner>gem env
Rubygems Environment:
- VERSION: 0.9.0 (0.9.0)
- INSTALLATION DIRECTORY: C:/ruby/lib/ruby/gems/1.8
- GEM PATH:
- C:/ruby/lib/ruby/gems/1.8
- REMOTE SOURCES:
- http://gems.rubyforge.org

C:\Documents and Settings\gavin.kistner>ruby -e 'require_gem "Usage"'
C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:251:in
`report_activate_error': Could not find RubyGem Usage (>= 0.0.0) (Gem:
:LoadError)
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:188:in
`activate'
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:66:in
`active_gem_with_options'
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:59:in
`require_gem'
from -e:1

C:\Documents and Settings\gavin.kistner>ruby -ve 'p ENV["GEM_HOME"]'
ruby 1.8.4 (2006-04-14) [i386-mswin32]
nil

C:\Documents and Settings\gavin.kistner>set
GEM_HOME=c:\ruby\lib\ruby\gems\1.8\gems

C:\Documents and Settings\gavin.kistner>ruby -e 'p ENV["GEM_HOME"];
require_gem "Usage"'
"c:\\ruby\\lib\\ruby\\gems\\1.8\\gems"
C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:251:in
`report_activate_error': Could not find RubyGem Usage (>= 0.0.0) (Gem:
:LoadError)
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:188:in
`activate'
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:66:in
`active_gem_with_options'
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:59:in
`require_gem'

I've also tried GEM_HOME settings of:
c:\ruby
c:\ruby\lib
c:\ruby\lib\ruby
c:\ruby\lib\ruby\gems
c:\ruby\lib\ruby\gems\1.8
c:\ruby\lib\ruby\gems\1.8\gems
all to no avail.
(I wish the rubygems documentation would provide examples of the
various environment variables.)
 
G

Gordon Thiesfeld

The problem is that rubygems can't find files that it itself installed.

Try: require 'usage'. The windows shell isn't case sensitive, but ruby is.

C:\Documents and Settings\gthiesfeld\desktop>irb
irb(main):001:0> require 'usage'
=> true
irb(main):002:0> exit

C:\Documents and Settings\gthiesfeld\desktop>gem list usage

*** LOCAL GEMS ***

usage (0.0.4)
This module implements a simple no thought command line option
parser

C:\Documents and Settings\gthiesfeld\desktop>gem list Usage

*** LOCAL GEMS ***

usage (0.0.4)
This module implements a simple no thought command line option
parser
 
P

Phrogz

Hrm, mine doesn't work quite like yours, but I got it to work.
Crazy-cased gem. Thanks.

To hijack my own thread: Why doesn't require work the same as
require_gem? Both find the Usage.rb file and load it, but using require
causes it not to properly run the "require_gem "SimpleTrace", "<=
0.1.0" command inside Usage.rb, resulting in the error shown in the
first block below:

===
# Thought it should work, given my RUBYOPT setting; but it doesn't.
# Case doesn't matter here, on Windows.
===
require 'Usage' # or require 'usage'; same effect

p Usage
#=> Usage

p Usage.new( "foo" )
C:/ruby/lib/ruby/gems/1.8/gems/usage-0.0.4/lib/Usage.rb:605:in
`initialize': undefined method `debug' for nil:NilClass (NoMethodError)
from C:/ruby/lib/ruby/gems/1.8/gems/usage-0.0.4/lib/Usage.rb:977:in
`initialize'
from tmp.rb:2



===
# Oops, bad case also caused me confusion.
===

require_gem 'Usage'
C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:251:in
`report_activate_error': Could not find RubyGem Usage (>= 0.0.0)
(Gem::LoadError)
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:188:in `activate'
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:66:in
`active_gem_with_options'
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:59:in `require_gem'
from tmp.rb:1



===
# Yay, the 'magic' combination that works!
===

require_gem 'usage'

p Usage
#=> Usage

p Usage.new( "foo" )
#=> PROGRAM: tmp.rb
#=> ERROR: too few arguments 1 expected, 0 given
#=>
#=> USAGE: tmp.rb foo
 
G

Gordon Thiesfeld

Umm, I was wrong. Disregard my last email. I'll try to think before I reply from now on.

irb(main):001:0> require 'Usage'
=> true
 
G

Gregory Brown

Hrm, mine doesn't work quite like yours, but I got it to work.
Crazy-cased gem. Thanks.

To hijack my own thread: Why doesn't require work the same as
require_gem? Both find the Usage.rb file and load it, but using require
causes it not to properly run the "require_gem "SimpleTrace", "<=
0.1.0" command inside Usage.rb, resulting in the error shown in the
first block below:

See http://redhanded.hobix.com/inspect/autorequireIsBasicallyGoneEveryone.html
This might help explain how require_gem works
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top