Error running gem install on Windows 7 64 bit

允我心安 提交于 2019-12-22 05:18:24

问题


I just installed ruby 1.9.2-p136 using the installer from rubyinstaller.org and now I am trying to install rails. When I do "gem install rails" I get the following error:

C:\Users\Clayton.USA>gem install rails
ERROR:  While executing gem ... (Errno::EINVAL)
    Invalid argument - P:/

Here are the ruby and gem versions I'm running:

C:\Users\Clayton.USA>ruby -v
ruby 1.9.2p136 (2010-12-25) [i386-mingw32]

C:\Users\Clayton.USA>gem -v
1.3.7

Update: found the solution here: How to stop the 'gem' utility from accessing my home directory?

Added the following to the start of my bin/gem:

ENV['HOME'] = "D:/Ruby192"

回答1:


In my case running following command from command prompt fixed the homedrive to c: and fixed the gem update issue
SET HOMEDRIVE=c:

your HOMEDRIVE was set to P:, after that command it will be set to C:
you can test by writing only
SET HOMEDRIVE
before and after setting it to C:




回答2:


You may not want to change your HOMEDRIVE (company laptops are often set with HOMERIVE to a network drive, which may be disconnected at the moment you execute the gem install). I think is not advisable either change the HOMEDRIVE or

stop the 'gem' utility from accessing my home directory

The correct solution to this question is to specify the HOME environment variable which is actually missing in your system. Rubygem always search for it before using the HOMEDRIVE. The simplest solution is then specify the new env variable:

SET HOME %USERPROFILE%




回答3:


I ran into this issue with a twist - same error but it was choking on quotes in the setrvbars.bat file in \Ruby\bin. My fix is on tumblr, but briefly:

This line read:

SET GEM_HOME=”C:\Ruby193\lib\ruby\gems\1.9.1”

Gem update was choking on the quotes. I dropped the quotes:

SET GEM_HOME=C:\Ruby193\lib\ruby\gems\1.9.1

And now it works fine.




回答4:


For some reason, the HOMEDRIVE is not set to the correct drive. To fix it, launch regedit from the run menu Go to HKEY_CURRENT_USER\Volatile Environment and change the HOMEDRIVE to your drive (C: in my case)



来源:https://stackoverflow.com/questions/4987300/error-running-gem-install-on-windows-7-64-bit

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