Ruby Forum Ruby > require not working on server

Posted by Jeff Pritchard (jeffpritchard)
on 18.08.2008 22:57
I'm developing on a Mac and deploying to a RHEL4 linux server.  For some
reason while "require" returns a boolean on the Mac, it is returning an
empty array "[]" on the server.  Where can I find the code for "require"
and what makes it return an empty array instead of a boolean?

This seems to be only in the Rails app I'm working on.  If I do this
same sequence in IRB, it works as expected on both machines.

Thanks much for any ideas/assistance...

jp



On the mac:
JP-iMac:synergy jeffpritchard$ script/console
Loading development environment (Rails 2.1.0)
>> require 'rubygems'
=> false
>> require 'redcloth'
=> true
>> RedCloth.new("fred").to_html
=> "<p>fred</p>"
>> quit


On the server:
[foo@bar current]# script/console
Loading development environment (Rails 2.1.0)
>> require 'rubygems'
=> []
>> require 'redcloth'
=> []
>> RedCloth.new("fred").to_html
NameError: uninitialized constant RedCloth::TextileDoc
  from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:275:in
`load_missing_constant'
  from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:467:in
`const_missing'
  from
/usr/lib/ruby/gems/1.8/gems/RedCloth-4.0.2/lib/case_sensitive_require/../redcloth.rb:17:in
`new'
  from (irb):3
>> 
Posted by Kyle Schmitt (Guest)
on 18.08.2008 23:52
(Received via mailing list)
On Mon, Aug 18, 2008 at 3:53 PM, Jeff Pritchard <jp@jeffpritchard.com> 
wrote:
> jp
>
>
>

RHEL4 is slightly...dated
Are you sure you've got the same versions of ruby on both platforms?
Posted by Jeff Pritchard (jeffpritchard)
on 19.08.2008 00:28
Kyle Schmitt wrote:
> On Mon, Aug 18, 2008 at 3:53 PM, Jeff Pritchard <jp@jeffpritchard.com> 
> wrote:
>> jp
>>
>>
>>
> 
> RHEL4 is slightly...dated
> Are you sure you've got the same versions of ruby on both platforms?

Yes, I have been updating ruby and rails as time went on.  Both at 1.8.6 
for ruby.  I know there is a 1.8.7, but some say it is not good with 
rails right now.

Also, I discovered that I had several older versions of ruby on the 
machine and have extirpated them all now.  That didn't fix it though. 
;(

thanks,
jp
Posted by Jeff Pritchard (jeffpritchard)
on 19.08.2008 00:48
Jeff Pritchard wrote:
Even if you don't have an idea to share, can somebody fill me in on how 
rubygems "works"?
Does the "require 'rubygems'" bring in some code that effectively 
replaces the ruby 'require'?

I see a bunch of stuff in "boot.rb" in the rails app that relates to 
rubygems.  Does this replace the ruby require mechanism as soon as the 
app starts up?  I have the latest rubygems installed.  It looks almost 
as though something must be going wrong with that.


> 
> thanks,
> jp
Posted by Kyle Schmitt (Guest)
on 19.08.2008 15:14
(Received via mailing list)
On Mon, Aug 18, 2008 at 5:45 PM, Jeff Pritchard <jp@jeffpritchard.com> 
wrote:
> Jeff Pritchard wrote:
> Even if you don't have an idea to share, can somebody fill me in on how
> rubygems "works"?
> Does the "require 'rubygems'" bring in some code that effectively
> replaces the ruby 'require'?

Well, more or less, I don't know.  But I know _some_ of it.
When you go back to 1.8.5,  you needed to
require 'rubygems'
#before you required a gem
require 'camping'

I think (for ready-made gems) mostly what it does is add path
information, but it also sets up logic to crawl the dependencies of a
gem, so it can load the libraries the gem requires, IFF they happen to
also be gems.

I'm pretty sure when 1.8.6 came out, however, you no longer needed to
require rubygems.  You could just:

require 'camping'

--Kyle