我使用
成功安装了bundlergem install bundler
然后我尝试做
bundle install
我收到以下错误:
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>'
似乎是环境变量的错误,但是在我的系统中正确设置了
set HOME
HOMEDRIVE=C:
HOMEPATH=\Users\My Näme
是的,我的名字里有斯堪的纳维亚字母,所以我想知道这是不是问题。我认为,在我使用web2py安装程序之前,我曾经遇到过这种情况。
无论如何,任何想法如何解决这个问题?
答案 0 :(得分:12)
如果您在域PC上并且您的PC设置为活动目录的一部分,则可能会遇到此问题。在这种情况下,您的企业活动目录或域中会设置HOMEPATH
,HOMEDRIVE
和HOME
个环境变量。一旦退出域组或与公司网络断开连接,您就会失去对这些变量的访问权限,从而导致错误。在Windows中使用setx
来获取永久环境变量以覆盖企业变量并重新启动系统以使其生效。
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%"
这是在Windows 10上测试的,它可以工作。将其复制并粘贴到脚本中,然后放入启动文件夹或在CMD
或PowerShell
中逐行粘贴。或者,使用Task Scheduler
设置为任务。
注意当使用带有双引号的setx
包含空格的字符串时。
答案 1 :(得分:0)
运行Get-ChildItem Env:
它将返回所有env变量。检查以确保HOME和HOMEPATH是正确的。
HOME -> C:\Users\Eric
HOMEPATH -> \Users\Eric
您可以使用以下命令修复:
Remove-Variable -Force HOME
Set-Variable HOME "C:\Users\(enter your username)"
答案 2 :(得分:0)
当我执行“ bundle exec jekyll s”时,我遇到相同的错误,这太奇怪了,以至于我以前从未遇到过该错误。然后,我尝试使用“ gem install bundler”重新安装捆绑包。然后另一个动人的表情显示:
ERROR: While executing gem ... (Errno::EACCES)
Permission denied @ rb_file_s_stat - C:/WINDOWS/system32/config/systemprofile
这给了我一个线索。我只是导航到目录并提供所需的权限。然后问题解决了。
今天真是美好的一天!