From: Christophe Broult Date: 2001-08-24T04:43:16+09:00 Subject: [ruby-talk:20202] cygwin and win32 interaction (RE: Re: Bug in re quire?) This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C12C0B.D13023E0 Content-Type: text/plain > -----Original Message----- > From: Dave Thomas [mailto:Dave@PragmaticProgrammer.com] > Sent: Thursday, August 23, 2001 3:27 PM > To: ruby-talk@ruby-lang.org > Subject: [ruby-talk:20200] Re: Bug in require? > > > Paul Brannan writes: > > > On another note, is there any way to require a file out of > the current > > directory? Currently, I am using: > > > > def requirelocal(file, *args) > > caller_file, *foo = caller[0].split(':') > > caller_dir = File.dirname(caller_file) > > require File.join(caller_dir, file) > > end > > In rubicon I use > > $: << File.dirname($0) << File.join(File.dirname($0), "..") > > to include the current directory and its parent in the search path. > > Of course this is a global change, but for my purposes this is OK. I tried to do this recently but that does not work because of a mix between cygwin paths and DOS paths. Here is an example of what I get: cd l:/ ruby L:/tmp/foo.rb ~/bin /cygdrive/d/cbroult-softs/ruby/lib/ruby/site_ruby/1.6/i386-cygwin /cygdrive/d/cbroult-softs/ruby/lib/ruby/site_ruby/1.6 /cygdrive/d/cbroult-softs/ruby/lib/ruby/site_ruby /cygdrive/d/cbroult-softs/ruby/lib/ruby/1.6/i386-cygwin /cygdrive/d/cbroult-softs/ruby/lib/ruby/1.6 . L:/tmp L:/tmp/foo.rb:6:in `require': No such file to load -- bar (LoadError) from L:/tmp/foo.rb:6 # foo.rb $: << File.dirname($0) puts $:.join("\n") puts require 'bar' # end foo.rb # bar.rb puts "#{$0} loaded" # end bar.rb Note that if I replace "ruby L:/tmp/foo.rb" with "ruby ~/tmp/foo.rb" this is working because my HOME var is set to "L:/". However I have a Ruby program on let's say D: this is not going to work. Any suggestion on that matter. Thank you for Ruby and all the contributed code, Christophe ------_=_NextPart_001_01C12C0B.D13023E0 Content-Type: text/html Content-Transfer-Encoding: quoted-printable cygwin and win32 interaction (RE: [ruby-talk:20200] Re: Bug in = require?)

> -----Original Message-----
> From: Dave Thomas [mailto:Dave@PragmaticProgra= mmer.com]
> Sent: Thursday, August 23, 2001 3:27 PM
> To: ruby-talk@ruby-lang.org
> Subject: [ruby-talk:20200] Re: Bug in = require?
>
>
> Paul Brannan <pbrannan@atdesk.com> = writes:
>
> > On another note, is there any way to = require a file out of
> the current
> > directory?  Currently, I am = using:
> >
> > def requirelocal(file, *args)
> >   caller_file, *foo =3D = caller[0].split(':')
> >   caller_dir =3D = File.dirname(caller_file)
> >   require File.join(caller_dir, = file)
> > end
>
> In rubicon I use
>
>    $: << File.dirname($0) = << File.join(File.dirname($0), "..")
>
> to include the current directory and its parent = in the search path.
>
> Of course this is a global change, but for my = purposes this is OK.

I tried to do this recently but that does not work = because of a mix between
cygwin paths and DOS paths. Here is an example of = what I get:


cd l:/
ruby L:/tmp/foo.rb
~/bin
/cygdrive/d/cbroult-softs/ruby/lib/ruby/site_ruby/1.6/i386-cygw= in
/cygdrive/d/cbroult-softs/ruby/lib/ruby/site_ruby/1.6
/cygdrive/d/cbroult-softs/ruby/lib/ruby/site_ruby
/cygdrive/d/cbroult-softs/ruby/lib/ruby/1.6/i386-cygwin
/cygdrive/d/cbroult-softs/ruby/lib/ruby/1.6
.
L:/tmp

L:/tmp/foo.rb:6:in `require': No such file to load -- = bar (LoadError)
        from = L:/tmp/foo.rb:6

# foo.rb
$: << File.dirname($0)

puts $:.join("\n")
puts

require 'bar'

# end foo.rb

# bar.rb
puts "#{$0} loaded"

# end bar.rb

Note that if I replace "ruby L:/tmp/foo.rb" = with "ruby ~/tmp/foo.rb" this is working because my HOME var = is set
to "L:/". However I have a Ruby program on = let's say D: this is not going to work.

Any suggestion on that matter.

Thank you for Ruby and all the contributed = code,

Christophe

------_=_NextPart_001_01C12C0B.D13023E0--