FileUtils missing

On my Windows box for the same exact project which works fine on my Mac
OS X box and on my Windows tablet I get the following error:

Process finished with exit code 1
I’m trying to make a call to FileUtils from within an inner class but
the Jruby compiler is getting confused and again just on my Windows box
? From the error it seems that the compiler wants to treat FileUtils as
if it was within the namespace of my inner class. That fact that it
works on my Mac and Win tablets suggests to me that I must have some
sort of setup wrong and possibly with Java SDK. Given that, I went
ahead and downloaded the latest JDK from Oracle i.e. jdk 7 update 9 ,
setup JAVA_HOME to point to it as I had done on my win tablet where
things work fine. Unfortunately that did not work. If I go ahead and
require “FileUtils” then I don’t’ get the error and the code works
except for a warning:

C:/Ruby193/lib/ruby/1.9.1/FileUtils.rb:93: warning: already initialized
constant OPT_TABLE
C:/Ruby193/lib/ruby/1.9.1/FileUtils.rb:1268: warning: already
initialized constant S_IF_DOOR
C:/Ruby193/lib/ruby/1.9.1/FileUtils.rb:1496: warning: already
initialized constant DIRECTORY_TERM
C:/Ruby193/lib/ruby/1.9.1/FileUtils.rb:1500: warning: already
initialized constant SYSCASE
C:/Ruby193/lib/ruby/1.9.1/FileUtils.rb:1619: warning: already
initialized constant LOW_METHODS
C:/Ruby193/lib/ruby/1.9.1/FileUtils.rb:1625: warning: already
initialized constant METHODS

which I find odd because I thought that Jruby is self contained i.e. ti
doesn’t go out of itself for Ruby functionality.

I’m a newbie, it seems that I may not understand the inter play between
Ruby and Jruby and Java for that matter.

BTW, all of this is running Intellij IDEA which seems to be what JRuby
central uses for development.

In conclusion, what possibly can be different in one environment from
another that would create the conditions that would correlate to what I
have described above ?

thanks again for the feedback.

Charles M.
[email protected]

Some inline responses, but the proper way to load the FileUtils code is
do:

require ‘fileutils’

The require ‘FileUtils’ version you’re doing works because macs and
windows
boxes are case insensitive when handling file names. However ruby isn’t,
so
require ‘fileutils’ and then require ‘FileUtils’ leads to it being
loaded
twice.

On Tue, Nov 13, 2012 at 9:34 PM, Charles M.
[email protected]wrote:

extract_misc at
Process finished with exit code 1

I’m trying to make a call to FileUtils from within an inner class but the
Jruby compiler is getting confused and again just on my Windows box ? From
the error it seems that the compiler wants to treat FileUtils as if it was
within the namespace of my inner class.

That’s just ruby’s way of saying “I don’t know what FileUtils is”. Ruby
defaults to trying to find your class in the closest scope it can (eg
nested near whatever modules/classes the code you’re running is in).

That fact that it works on my Mac and Win tablets suggests to me that I
must have some sort of setup wrong and possibly with Java SDK.

Someone may correct me, but I’d be pretty surprised if this had anything
to
do with your java version. This is an issue in ruby land.

C:/Ruby193/lib/ruby/1.9.1/FileUtils.rb:1496: warning: already initialized

See my initial blurb for why this is happening. You can reproduce this
on
your other machine by doing:

require ‘fileutils’
require ‘FileUtils’ # will drop the warnings
require ‘FIleUtils # will drop the warnings’

And also, that warning just means you’re trying to set a constant that’s
already been set. That happens because when the require runs multiple
times, the code in that file runs, and that code happens to set some
constants.

In conclusion, what possibly can be different in one environment from

another that would create the conditions that would correlate to what I
have described above ?

Try putting require ‘fileutils’ in your script, and see if you get the
same
behavior. I’m not sure why you’re not seeing weirdness on your mac, how
do
you run the script there?

On Nov 13, 2012, at 10:46 PM, Richie V. [email protected] wrote:

Some inline responses, but the proper way to load the FileUtils code is do:

require ‘fileutils’

The require ‘FileUtils’ version you’re doing works because macs and windows
boxes are case insensitive when handling file names. However ruby isn’t, so
require ‘fileutils’ and then require ‘FileUtils’ leads to it being loaded twice.

Just FYI: HFS+, which is still the default for the Mac OS X, can be
case-sensitive or insensitive. It is not an OS issue. Assuming it is, or
it isn’t, can surprise you when you least expect it.

On Tue, Nov 13, 2012 at 9:34 PM, Charles M. [email protected]
wrote:

If I go ahead and require “FileUtils” then I don’t’ get the error and the code
works except for a warning:

C:/Ruby193/lib/ruby/1.9.1/FileUtils.rb:93: warning: already initialized constant
OPT_TABLE
C:/Ruby193/lib/ruby/1.9.1/FileUtils.rb:1268: warning: already initialized
constant S_IF_DOOR
C:/Ruby193/lib/ruby/1.9.1/FileUtils.rb:1496: warning: already initialized
constant DIRECTORY_TERM
C:/Ruby193/lib/ruby/1.9.1/FileUtils.rb:1500: warning: already initialized
constant SYSCASE
C:/Ruby193/lib/ruby/1.9.1/FileUtils.rb:1619: warning: already initialized
constant LOW_METHODS
C:/Ruby193/lib/ruby/1.9.1/FileUtils.rb:1625: warning: already initialized
constant METHODS

Yeah this is odd as it implies you are loading fileutils from C Ruby’s
1.9 directory and not JRuby’s. You likely have some ENV var set which
is causing you to load their stdlib rather than ours. This is an
independent issue from what others have already mentioned.

-Tom


blog: http://blog.enebo.com twitter: tom_enebo
mail: [email protected]