m5seppal
m5seppal

Reputation: 1226

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?

Upvotes: 5

Views: 12224

Answers (3)

Allen Vork
Allen Vork

Reputation: 1546

I get the same error when i was excuting "bundle exec jekyll s" Which is so weird that I have never got the error before. Then I tried to reinsall the bundle with "gem install bundler". Then another wanring showed:

ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ rb_file_s_stat - C:/WINDOWS/system32/config/systemprofile

It gives me a clue. I just navigate to the directory and give the permission it needs. Then the problem is solved.
What a beautiful day it is!

Upvotes: 0

Eric Hasselbring
Eric Hasselbring

Reputation: 1424

Run Get-ChildItem Env: it will return all your env variables. Check to make sure HOME and HOMEPATH are correct.

HOME -> C:\Users\Eric HOMEPATH -> \Users\Eric

You can use commands below to fix: Remove-Variable -Force HOME Set-Variable HOME "C:\Users\(enter your username)"

Upvotes: 1

Julius Krah
Julius Krah

Reputation: 422

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.

Upvotes: 23

Related Questions