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

后端 未结 6 1422
挽巷
挽巷 2021-02-01 06:16

When I run

gem install 

command the gem utility tries to access my home directory. It contains some non-latin char

相关标签:
6条回答
  • 2021-02-01 06:52

    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.

    0 讨论(0)
  • 2021-02-01 06:53

    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.

    0 讨论(0)
  • 2021-02-01 06:53

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

    0 讨论(0)
  • 2021-02-01 06:55

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

    0 讨论(0)
  • 2021-02-01 07:06

    Perhaps try changing the value of the GEM_HOME environment directory?

    0 讨论(0)
  • 2021-02-01 07:10

    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

    0 讨论(0)
提交回复
热议问题