views:

1112

answers:

4

When I run

gem install <somegem>

command the gem utility tries to access my home directory. It contains some non-latin characters and installation fails because of that. For example:

E:\ruby\bin>gem install <somegem>
ERROR:  While executing gem ... (Errno::ENOENT)
    No such file or directory - C:\Documents and Settings\<user>

If I switch to another user account with a username containing ASCII characters only gem works fine.

Does anybody know how to tell gem NOT to check my home directory?

UPDATE: I tried to set up GEM_HOME as suggested below but it didn't help (still checks the user home directory)

A: 

Perhaps try changing the value of the GEM_HOME environment directory?

ry
A: 

If you GEM_PATH is set to your user directory, it will still access it. Try changing GEM_HOME and GEM_PATH.

MickTaiwan
+5  A: 

Just change HOMEDRIVE and HOMEPATH before running gem, and restore after (if needed).

I've changed my gem.bat like this:

@ECHO OFF
SET _HOMEDRIVE=%HOMEDRIVE%
SET _HOMEPATH=%HOMEPATH%
SET HOMEDRIVE=E:
SET HOMEPATH=/Dev/Ruby
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "E:/Dev/Ruby/bin/gem" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*
SET HOMEDRIVE=%_HOMEDRIVE%
SET HOMEPATH=%_HOMEPATH%

E:/Dev/Ruby/ is my Ruby path. It seems that HOMEPATH can be changed to anything else with ASCII only characters in path.

Sergey 'm17' Kolosov
Another, better way is to set HOME environment variable in “gem” script itself. Add following line to the beginning of “bin/gem”:ENV['HOME'] = "E:/Dev/Ruby"This fix works for all “gem” usages. As previously mentioned, this path can be changed, using ruby dir isn't required.
Sergey 'm17' Kolosov
Those script changes worked a treat with my Windows7. Thanks!
Falkayn
Thanks for this. Works in Vista well
Ivan Nevostruev
Works like a charm. They really should fix this though
D0cNet
A: 

у меня заработало только после того как переопределил APPDATA и USERPROFILE и для переопределения путей можно использовать сокращенные названия папок которые можно посмотреть в переменной TEMP или TMP через комманду SET

I have earned only after re-defined APPDATA and USERPROFILE and to redefine the ways you can use the abbreviated names of the folders which can be seen in the variable TEMP or TMP through command SET