As someone who is new to Ruby I really love the idea of installing what you need for the language through gems. However, when I am at work I am on my company’s domain and when I try to install a gem I get the following error:
ERROR: While executing gem ... (Errno::ENOENT)
No such file or directory - H:\
After searching for a solution to this problem, I believe I have found one.
The problem stems from the fact that logging into my domain at work changes my %HOMEDRIVE% and %HOMEPATH% environment variables to my networked H:\ drive. To solve this problem you need to change your gem.bat.
The gem.bat file is located in your RubyFolder\bin folder. I would suggest that you first make a copy of the original before any tweaking of this file. What you are going to do is modify this file so that it changes the %HOMEDRIVE% and %HOMEPATH% before it tries to install the gem and then, when it is done, change those environment variables back to the original values. Below is an example of what you want this file to look like when you are done.
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "C:/Ruby192/bin/gem" %1 %2 %3 %4 %5 %6 %7 %8 %9
@"ruby.exe" "%~dpn0" %*
In the above example, Ruby192 is where Ruby is installed.
So if you are stuck behind on a domain and cannot install a much needed Ruby gem, this solution will get you back in business in no time.
I cannot take credit for this solution so here are some places where I found this solution