On Fri, 13 Jan 2006 13:12:02 +0100, Mojca Miklavec  
<mojca.miklavec.lists / gmail.com> wrote:

> Hello,
>
> I'm using a script located under
>     c:\mypath\myscript.rb
> which has
>     require 'mylib'
> (I have another file c:\mypath\mylib.rb.)
>
> If I call ruby, the cygwin executable is called (I have no admin
> rights on the computer, so I can't afford to install another native
> windows version of ruby.)
>
> Now the problem:
> If I go to c:\mypath and call myscript from there, everything works OK.
> File.dirname(__FILE__) is set to "/cygdrive/c/mypath" and properly
> included in $LOAD_PATH.
>
> But if I execute the script from somewhere else, inclusion doesn't
> work any more:
>
> C:/mypath/myscript.rb:10:in `require': No such file to load -- mylib  
> (LoadError)
>         from C:/mypath/myscript.rb:10
>
> since File.dirname(__FILE__) is now set to "c:\mypath" and this one
> also gets included in $LOAD_PATH. But cygwin cannot access that path
> by default.
>
> After adding
>     $LOAD_PATH << '/cygdrive/c/mydir'
> to the script it works again, but I may not afford to modify the
> script by hardcoding the path into it since it has to work on other
> computers as well.
>
> Is there a way to modify the script (in a compatible way with the rest
> of the world) or (preferrably) to change the settings in cygwin
> somehow, so that the inclusion will work again without hardcoding the
> path?
>
> Any help would be appreciated,
>     Mojca Miklavec
>


I'd guess thst's because the Cygwin ruby expects a POSIX path, not the  
Windows one. The wonderful tool Cygwin is, it doesn't do miracles - you  
should always use Cygwin tools from a Cygwin shell, not from CMD or by  
putting them on the path by default. The first case works because for a  
file in the current directory is the same as the Cygwin POSIX path.

If you can use bash, I'd say switch to using the Cygwin shell on that  
machine.

David Vallner