Load bug?

require ‘…/ext/rubyeventmachine’
=> true

require ‘eventmachine’

hmm.
Typically this works. On my newest machine, however, it errs as above.
LoadError: no such file to load – rubyeventmachine

It’s trying to load the file that I just required one line above,
successfully.

I assume this is a bug?

Info:
the file it is trying to load is ‘…/ext/rubyeventmachine.bundle’
If I copy that file to the local directory [or sym link it in] then

require ‘eventmachine’
=> true
loads like a charm.

Egh. Looks like an obscure bug to me. Might be OS X only, anyway.
-R

Roger P. [email protected] writes:

I assume this is a bug?

No, it’s not, it’s just what Ruby does. Some people would argue that
Ruby should be a bit more helpful here, but once you know the rule,
it’s not that big of a deal.

When loading a file with require, Ruby will remember the name of the
file you loaded, and not load it again. The trick here is, it only
remembers the name you give it, so if you refer to the same file using
a different path, Ruby will load the file a second time.

All of the following will load the same file several times.

,----
| require ‘foo.rb’
| require ‘./foo.rb’
| require ‘…/foo/foo.rb’
`----

the file it is trying to load is ‘…/ext/rubyeventmachine.bundle’
If I copy that file to the local directory [or sym link it in] then

require ‘eventmachine’
=> true
loads like a charm.

Egh. Looks like an obscure bug to me. Might be OS X only, anyway.

Looks like a bad LOADPATH to me.

On May 17, 2008, at 10:22 PM, Roger P. wrote:

I assume this is a bug?

it’s been a ‘feature’ up until 1.9, which fixes. this.

typically i’ll write all my production code to use absolute require
paths. also, production libs can/should be protected via:

unless defined? MyCode

module MyCode

end

end

etc.

a @ http://codeforpeople.com/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs