I have two files foo.rb and test.rb in the same folder.
test.rb
------------------------------------
puts RUBY_VERSION
require 'foo'
------------------------------------
foo.rb
------------------------------------
module Foo
PATTT = "2323"
class Foo2
def f
puts 'hello world'
end
end
end
puts 'eee'
------------------------------------
Running under NetBeans it's OK. But running test.rb through concole OR
RubyMine fails with:
C:\USERS\ADMIN>ruby
C:\Users\Admin\Documents\NetBeansProjects\RubyApplication1\l
ib\test.rb
1.9.1
C:/Users/Admin/Documents/NetBeansProjects/RubyApplication1/lib/test.rb:2:in
`req
uire': no such file to load -- foo (LoadError)
from
C:/Users/Admin/Documents/NetBeansProjects/RubyApplication1/lib/test
rb:2:in `<main>'
--
Posted via http://www.ruby-forum.com/.
|
|
0
|
|
|
|
Reply
|
Svin
|
4/29/2010 5:34:09 PM |
|
On Apr 29, 2:34=A0pm, Svin Svin <svi...@ya.ru> wrote:
> I have two files foo.rb and test.rb in the same folder.
>
> test.rb
> ------------------------------------
> puts RUBY_VERSION
> require 'foo'
> ------------------------------------
>
> foo.rb
> ------------------------------------
> module Foo
> =A0 PATTT =3D "2323"
> =A0 class Foo2
> =A0 =A0 def f
> =A0 =A0 =A0 puts 'hello world'
> =A0 =A0 end
> =A0 end
> end
>
> puts 'eee'
> ------------------------------------
>
> Running under NetBeans it's OK. But running test.rb through concole OR
> RubyMine fails with:
>
> C:\USERS\ADMIN>ruby
> C:\Users\Admin\Documents\NetBeansProjects\RubyApplication1\l
> ib\test.rb
> 1.9.1
> C:/Users/Admin/Documents/NetBeansProjects/RubyApplication1/lib/test.rb:2:=
in
> `req
> uire': no such file to load -- foo (LoadError)
> =A0 =A0 =A0 =A0 from
> C:/Users/Admin/Documents/NetBeansProjects/RubyApplication1/lib/test
> rb:2:in `<main>'
Simple: you're trying to require 'foo' from a directory that is not
the current one.
If both test.rb and foo.rb are located in the same directory, doing
"ruby path\to\test.rb" will not be able to find foo in the same path.
Now, if you CD into the directory test.rb and foo.rb are located,
require 'foo' will succeed, since the current directory is in the
$LOAD_PATH.
That helps?
--
Luis Lavena
|
|
0
|
|
|
|
Reply
|
Luis
|
4/29/2010 6:46:35 PM
|
|
> Simple: you're trying to require 'foo' from a directory that is not
> the current one.
>
> If both test.rb and foo.rb are located in the same directory, doing
> "ruby path\to\test.rb" will not be able to find foo in the same path.
>
> Now, if you CD into the directory test.rb and foo.rb are located,
> require 'foo' will succeed, since the current directory is in the
> $LOAD_PATH.
>
> That helps?
Thanks, it helps!
Why it's so different from python/java :(
--
Posted via http://www.ruby-forum.com/.
|
|
0
|
|
|
|
Reply
|
Svin
|
4/29/2010 7:01:37 PM
|
|