Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows bundle install: HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory (RuntimeError)

I installed bundler succesfully with

gem install bundler

Then I try to do

bundle install

I get following error:

C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rbreadline.rb:1097:in `<module:RbReadline>': HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory (RuntimeError)
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rbreadline.rb:17:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/readline.rb:10:in `<module:Readline>'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/readline.rb:8:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb:2:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/line_editor.rb:2:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/base.rb:8:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor.rb:2:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/vendored_thor.rb:3:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:4:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.12.5/exe/bundle:18:in `<top (required)>'
    from C:/Ruby22-x64/bin/bundle:22:in `load'
    from C:/Ruby22-x64/bin/bundle:22:in `<main>'

Seems to be error with environment variables, however those are set properly in my system

set HOME
HOMEDRIVE=C:
HOMEPATH=\Users\My Näme

Yes, I have scandinavian letter in my name so I'm wondering if that is the problem. I've faced that once before with web2py installer I think.

Anyway, any ideas how to solve that problem?

like image 559
m5seppal Avatar asked Aug 27 '16 09:08

m5seppal


People also ask

Where are Homedrive homepath set?

HOMEDRIVE , HOMEPATH and HOMESHARE (as well as several other variables) are set by shell32! RegenerateUserEnvironment which is called on Explorer initialization1. They are placed in the (volatile) HKCU\Volatile Environment key which, being volatile, persists until the profile's unload.

Where is homepath defined?

On a Microsoft Windows system, the path: D:\ is known as the HOMEPATH.


1 Answers

You are likely to face this problem if you are on a domain PC and your PC is setup as part of an active directory. In this case your HOMEPATH, HOMEDRIVE and HOME environment variables are set in your enterprise active directory or domain. Once out of the domain group or when disconnected from company network you loose access to these variables hence the error. Use setxin windows for permanent environment variables to override enterprise ones and restart your system for it to take effect.

SETX HOMEDRIVE %SYSTEMDRIVE% -m
SETX HOMEPATH \Users\%username% -m
SET HOME=%SYSTEMDRIVE%\Users\%USERNAME%
SETX HOME "%HOME%"
SET TEMP=%HOME%\Local Settings\Temp
SETX TEMP "%TEMP%"
SETX TMP "%TEMP%"

This is tested on windows 10 and it works. Either copy and paste it in a script and drop in your startup folder or paste it line by line in CMD or PowerShell. Alternatively set is as task using Task Scheduler. Note When using setx wrap strings with spaces in them with double quotes.

like image 84
Julius Krah Avatar answered Oct 19 '22 23:10

Julius Krah