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

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


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

I've changed my gem.bat like this:

@ECHO OFFSET _HOMEDRIVE=%HOMEDRIVE%SET _HOMEPATH=%HOMEPATH%SET HOMEDRIVE=E:SET HOMEPATH=/Dev/RubyIF NOT "%~f0" == "~f0" GOTO :WinNT@"ruby.exe" "E:/Dev/Ruby/bin/gem" %1 %2 %3 %4 %5 %6 %7 %8 %9GOTO :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.


It's simpler to write:

@ECHO OFFSET HOMEPATH=IF NOT "%~f0" == "~f0" GOTO :WinNTECHO.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


Perhaps try changing the value of the GEM_HOME environment directory?