[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

expand_path on windows for home dir

Roger Pack

5/28/2009 1:39:00 PM

currently on windows we've got:

>> File.expand_path '~'
=> "/Documents and Settings/Melissa.BLACKY"

shouldn't it be
>> File.expand_path '~'
=> "c:/Documents and Settings/Melissa.BLACKY"

?
-=r
--
Posted via http://www.ruby-....

4 Answers

Heesob Park

5/28/2009 2:03:00 PM

0

Hi,

2009/5/28 Roger Pack <rogerpack2005@gmail.com>:
> currently on windows we've got:
>
>>> File.expand_path '~'
> => "/Documents and Settings/Melissa.BLACKY"
>
> shouldn't it be
>>> File.expand_path '~'
> => "c:/Documents and Settings/Melissa.BLACKY"
>
> ?
> -=r
What's your Ruby version?
In my test, it works as expected:

C:\>ruby -ve 'p File.expand_path("~")'
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mswin32]
"C:/Documents and Settings/phasis"

Regards,
Park Heesob

Roger Pack

5/28/2009 2:14:00 PM

0


> C:\>ruby -ve 'p File.expand_path("~")'
> ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mswin32]
> "C:/Documents and Settings/phasis"

Odd:

D:\dev>c:ruby -ve 'p File.expand_path("~")'
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mingw32]
"/Documents and Settings/Melissa.BLACKY"

maybe I should try p0 again :)
My guess is it's some compiler define not set right.
-=r
--
Posted via http://www.ruby-....

Daniel Berger

5/28/2009 4:07:00 PM

0



> -----Original Message-----
> From: rogerpack2005@gmail.com [mailto:rogerpack2005@gmail.com]
> Sent: Thursday, May 28, 2009 8:14 AM
> To: ruby-talk ML
> Subject: Re: expand_path on windows for home dir
>
>
> > C:\>ruby -ve 'p File.expand_path("~")'
> > ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mswin32]
> > "C:/Documents and Settings/phasis"
>
> Odd:
>
> D:\dev>c:ruby -ve 'p File.expand_path("~")'
> ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mingw32]
> "/Documents and Settings/Melissa.BLACKY"
>
> maybe I should try p0 again :)
> My guess is it's some compiler define not set right.

What's your ENV['HOME'], ENV['HOMEDRIVE'] and ENV['USERPROFILE'] set to?

Does it work if you try it from C:\ on the command line instead of D:\ ?
Regards,

Dan


Roger Pack

5/29/2009 11:14:00 PM

0


> What's your ENV['HOME'], ENV['HOMEDRIVE'] and ENV['USERPROFILE'] set to?

Odd. Works great on one computer of mine and on the other (which has
HOME HOMEDRIVE AND USERPROFILE all set) it doesn't. Any version of
ruby.
Odd. Well I'm glad to know that by default it includes the drive
letter, which is right. Luis if you're reading this might explain the
weird gem installation to different drives issue.
Thanks for your help all.
-=r
--
Posted via http://www.ruby-....