How to stop the 'gem' utility from accessing my home directory?

不羁岁月 提交于 2019-12-20 09:17:47

问题


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)


回答1:


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.




回答2:


It's simpler to write:

@ECHO OFF
SET HOMEPATH=
IF NOT "%~f0" == "~f0" GOTO :WinNT
ECHO.This version of Ruby has not been built with support for Windows 95/98/Me.
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*

In this case you don't need to write your path and can replace or redistribute with file for new installations




回答3:


Perhaps try changing the value of the GEM_HOME environment directory?




回答4:


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




回答5:


just run postinstall file pi.bat or pi.sh this file is in ./RubyDevKit/postinstall.

this worked for me. it seems that installer of cygwin broke my settings.




回答6:


Restart the command prompt console as something might have jacked it up. I had the same issue, and restarting the console reset my environment.



来源:https://stackoverflow.com/questions/849660/how-to-stop-the-gem-utility-from-accessing-my-home-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!