Console/Server fetching different gems

Hey All,

I’m running into a situation where ruby script/server and ruby
script/console are apparently not pulling gems from the same directory.
Ex:

$> ruby script/console

require ‘nokogiri’
=> []
Nokogiri
=>Nokogiri

When I do it with script/server I get the following behaviour

$ ruby script/server
=> Booting WEBrick
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
Ruby/Extensions: Array#rand is already defined; not overwriting
Ruby/Extensions: Binding#eval is already defined; not overwriting
Ruby/Extensions: Enumerable#none? is already defined; not overwriting
Ruby/Extensions: Enumerable#one? is already defined; not overwriting
Ruby/Extensions: Integer#even? is already defined; not overwriting
Ruby/Extensions: Integer#odd? is already defined; not overwriting
Ruby/Extensions: String#starts_with? is already defined; not overwriting
Ruby/Extensions: String#ends_with? is already defined; not overwriting
Ruby/Extensions: Symbol#to_proc is already defined; not overwriting
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2009-11-08 15:13:55] INFO WEBrick 1.3.1
[2009-11-08 15:13:55] INFO ruby 1.8.7 (2009-06-12) [i686-darwin10.0.0]
[2009-11-08 15:13:55] INFO WEBrick::HTTPServer#start: pid=96403
port=3000
nil
SQL (0.2ms) SET NAMES ‘utf8’
SQL (0.1ms) SET SQL_AUTO_IS_NULL=0

Processing FeedController#create (for 127.0.0.1 at 2009-11-08 15:14:00)
[POST]
Parameters: {“commit”=>“Add”,
“authenticity_token”=>“fpXtb6uJPmunPMS8hUKisGIXdeTxM+Odefrtzxlvq8o=”,
“feed”=>{“feed_url”=>"Quality Health is momentarily down...
"}}
Cached fragment hit:
views/localhost:3000/homepage/homepage?left_navigation=top_feeds (0.2ms)
Cached fragment hit:
views/localhost:3000/homepage/homepage?left_navigation=top_categories
(0.2ms)
Cached fragment hit:
views/localhost:3000/homepage/homepage?left_navigation=top_media (0.2ms)
Feed Columns (1.5ms) SHOW FIELDS FROM feeds

MissingSourceFile (no such file to load – nokogiri):
lib/sax-machine/sax_document.rb:1
lib/sax-machine.rb:5
lib/feedzirra.rb:7
app/models/feed.rb:50:in update_feed' app/controllers/feed_controller.rb:16:in create’
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in service' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in run’
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in start’
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:95:in start’
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in each' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in start’
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in start' /usr/local/lib/ruby/1.8/webrick/server.rb:82:in start’

Rendered rescues/_trace (110.2ms)
Rendered rescues/_request_and_response (3.0ms)
Rendering rescues/layout (internal_server_error)

Firstly, am I correct to assume that I should not be seeing different
behavior with each environment?

Any idea why this would be happening? I assume that my server is
misconfigured in some way. What should I be looking for?

Thanks,
Jim

Hi James E.

Have you configured gem in config/environment.rb using
config.gem and also require ‘nokogiri’ where you use it?

Sijo

On Nov 9, 1:03 am, Sijo k g [email protected] wrote:

Hi James E.

Have you configured gem in config/environment.rb using
config.gem and also require ‘nokogiri’ where you use it?

Note that you shouldn’t need the require - config.gem does that
automatically.

–Matt J.

Yeah. I’ve tried both requiring the file and using the config.gem. I
didn’t
have much luck either way.

On Mon, Nov 9, 2009 at 1:03 AM, Sijo k g

Yeah. The #! line is the same in both cases. It’s the stragest thing.
I’m
starting to believe I might have my rubygems pointing to two different
system gem locations (well, three including the non-root version). Is
there
a command that you can run in ruby to determine where rubygems is
pulling
the gems?

On Nov 8, 3:12 pm, James E. [email protected] wrote:

Hey All,

I’m running into a situation where ruby script/server and ruby
script/console are apparently not pulling gems from the same directory. Ex:

[snip]

Firstly, am I correct to assume that I should not be seeing different
behavior with each environment?

Any idea why this would be happening? I assume that my server is
misconfigured in some way. What should I be looking for?

Thanks,
Jim

Do script/console and script/server have the same #! line? I remember
that Perl would “helpfully” run whatever interpreter was in there
(even if it wasn’t Perl!), and Ruby may have inherited similar
behavior.

–Matt J.