This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Loading cygwin libraries in Ruby from CMD?


This may not be a cygwin issue at all, but it never hurts to ask...

I'm using the Ruby library RMagick (http://rmagick.rubyforge.org) with ruby
1.8.4, which I've successfully built under Cygwin.  When I launch IRB (the
interactive ruby interpreter) from bash, and type "require 'RMagick'", it
loads successfully.  Ditto for a script running from /usr/local/bin/ruby.

However, when I do the same from CMD.EXE, I get an error:

/usr/lib/ruby/site_ruby/1.8/RMagick.rb:28: uninitialized constant
Magick::Enum (NameError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from jaytest.rb:1

Using Filemon from Sysinternals (http://www.sysinternals.com), it appears
that ruby.exe loads RMagick.rb successfully.  It then attempts to load
RMagick.so; it finds it, but apparently bypasses it and continues looking
for it in every possible directory in its library path.

My suspicion is that there's something different about the environment
running from cmd.exe rather than bash, and cygwin (or ruby) decides that
i386-cygwin/RMagick.so isn't the right file to be loading for this
environment.

Ruby itself has a variable called RUBY_PLATFORM, but that is properly set
to i386-cygwin when running from cmd.  I've tried manually adding cygwin's
/bin, /usr/bin, etc. to %PATH%, to emulate cygwin.bat, but it didn't make a
difference.  I was told that incorrect library paths could cause this error
on some systems, but Cygwin doesn't use ld.so.conf. 
  
Any ideas what I could look at to see why RMagick.so isn't being loaded?
One interesting bit from strace is below - there's an error 126 (module not
found), which is odd, because clearly it has found the file.

Jay Levitt

----------------


   80 1927836 [main] ruby 1348 open: open
(/usr/lib/ruby/site_ruby/1.8/i386-cygwin/RMagick.so, 0x0)
   35 1927871 [main] ruby 1348 normalize_posix_path: src
/usr/lib/ruby/site_ruby/1.8/i386-cygwin/RMagick.so
   35 1927906 [main] ruby 1348 normalize_posix_path:
/usr/lib/ruby/site_ruby/1.8/i386-cygwin/RMagick.so = normalize_posix_path
(/usr/lib/ruby/site_ruby/1.8/i386-cygwin/RMagick.so)
   37 1927943 [main] ruby 1348 mount_info::conv_to_win32_path:
conv_to_win32_path (/usr/lib/ruby/site_ruby/1.8/i386-cygwin/RMagick.so)
   38 1927981 [main] ruby 1348 set_flags: flags: binary (0x2)
   35 1928016 [main] ruby 1348 mount_info::conv_to_win32_path: src_path
/usr/lib/ruby/site_ruby/1.8/i386-cygwin/RMagick.so, dst
C:\cygwin\lib\ruby\site_ruby\1.8\i386-cygwin\RMagick.so, flags 0xA, rc 0
   58 1928074 [main] ruby 1348 symlink_info::check: not a symlink
   36 1928110 [main] ruby 1348 symlink_info::check: 0 = symlink.check
(C:\cygwin\lib\ruby\site_ruby\1.8\i386-cygwin\RMagick.so, 0x240AAF0) (0xA)
   37 1928147 [main] ruby 1348 path_conv::check:
this->path(C:\cygwin\lib\ruby\site_ruby\1.8\i386-cygwin\RMagick.so),
has_acls(1)
   37 1928184 [main] ruby 1348 build_fh_pc: fh 0x6115CE7C
   37 1928221 [main] ruby 1348 fhandler_base::open:
(C:\cygwin\lib\ruby\site_ruby\1.8\i386-cygwin\RMagick.so, 0x100000)
  211 1928432 [main] ruby 1348 fhandler_base::set_flags: flags 0x100000,
supplied_bin 0x10000
   39 1928471 [main] ruby 1348 fhandler_base::set_flags: filemode set to
binary
   35 1928506 [main] ruby 1348 fhandler_base::open: 0 = NtCreateFile
(0x6F8, 80100000, C:\cygwin\lib\ruby\site_ruby\1.8\i386-cygwin\RMagick.so,
io, NULL, 0, 7, 1, 20, NULL, 0)
   38 1928544 [main] ruby 1348 fhandler_base::open: 1 = fhandler_base::open
(C:\cygwin\lib\ruby\site_ruby\1.8\i386-cygwin\RMagick.so, 0x100000)
   36 1928580 [main] ruby 1348 fhandler_base::open_fs: 1 =
fhandler_disk_file::open
(C:\cygwin\lib\ruby\site_ruby\1.8\i386-cygwin\RMagick.so, 0x0)
   36 1928616 [main] ruby 1348 open: 3 = open
(/usr/lib/ruby/site_ruby/1.8/i386-cygwin/RMagick.so, 0x0)
   55 1928671 [main] ruby 1348 _cygwin_istext_for_stdio: fd 3: opened as
binary
   95 1928766 [main] ruby 1348 close: close (3)
   34 1928800 [main] ruby 1348 fhandler_base::close: closing
'/usr/lib/ruby/site_ruby/1.8/i386-cygwin/RMagick.so' handle 0x6F8
   49 1928849 [main] ruby 1348 close: 0 = close (3)
  244 1929093 [main] ruby 1348 normalize_posix_path: src
/usr/lib/ruby/site_ruby/1.8/i386-cygwin/RMagick.so
   39 1929132 [main] ruby 1348 normalize_posix_path:
/usr/lib/ruby/site_ruby/1.8/i386-cygwin/RMagick.so = normalize_posix_path
(/usr/lib/ruby/site_ruby/1.8/i386-cygwin/RMagick.so)
   37 1929169 [main] ruby 1348 mount_info::conv_to_win32_path:
conv_to_win32_path (/usr/lib/ruby/site_ruby/1.8/i386-cygwin/RMagick.so)
   36 1929205 [main] ruby 1348 set_flags: flags: binary (0x2)
   35 1929240 [main] ruby 1348 mount_info::conv_to_win32_path: src_path
/usr/lib/ruby/site_ruby/1.8/i386-cygwin/RMagick.so, dst
C:\cygwin\lib\ruby\site_ruby\1.8\i386-cygwin\RMagick.so, flags 0xA, rc 0
   57 1929297 [main] ruby 1348 symlink_info::check: not a symlink
   37 1929334 [main] ruby 1348 symlink_info::check: 0 = symlink.check
(C:\cygwin\lib\ruby\site_ruby\1.8\i386-cygwin\RMagick.so, 0x240AB80) (0xA)
   36 1929370 [main] ruby 1348 path_conv::check:
this->path(C:\cygwin\lib\ruby\site_ruby\1.8\i386-cygwin\RMagick.so),
has_acls(1)
 3763 1933133 [main] ruby 1348 seterrno_from_win_error:
/netrel/src/cygwin-1.5.19-4/winsup/cygwin/dlfcn.cc:103 windows error 126
   99 1933232 [main] ruby 1348 geterrno_from_win_error: windows error 126
== errno 2
   37 1933269 [main] ruby 1348 __set_errno: void
seterrno_from_win_error(const char*, int, DWORD):310 val 2
   37 1933306 [main] ruby 1348 dlopen: ret 0x0


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]