即使设置了 HOME 变量,Bundler 也会死机
Posted
技术标签:
【中文标题】即使设置了 HOME 变量,Bundler 也会死机【英文标题】:Bundler dying even though HOME variable is set 【发布时间】:2018-08-17 09:20:06 【问题描述】:我的问题与issue deploying rails 5 application to AWS using Elastic Beanstalk due to rb-readline中描述的问题非常相似
但是,通过 AWS 控制台设置 HOME 和/或 HOMEPATH 并没有帮助。我每次都遇到同样的错误。这是相关的日志文件:
/var/log/eb-activity.log
++ export PATH=/opt/rubies/ruby-2.3.4/bin:/opt/elasticbeanstalk/lib/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
++ PATH=/opt/rubies/ruby-2.3.4/bin:/opt/elasticbeanstalk/lib/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
+++ /opt/rubies/ruby-2.3.4/bin/ruby -
++ eval 'export RUBY_ENGINE=ruby;
export RUBY_VERSION=2.3.4;
export GEM_ROOT="/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0";'
+++ export RUBY_ENGINE=ruby
+++ RUBY_ENGINE=ruby
+++ export RUBY_VERSION=2.3.4
+++ RUBY_VERSION=2.3.4
+++ export GEM_ROOT=/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0
+++ GEM_ROOT=/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0
++ (( 0 != 0 ))
+ cd /var/app/ondeck
+ su -s /bin/bash -c 'bundle exec /opt/elasticbeanstalk/support/scripts/check-for-rake-task.rb assets:precompile' webapp
`/home/webapp` is not a directory.
Bundler will use `/tmp/bundler/home/webapp' as your home directory temporarily.
+ '[' false == true ']'
+ su -s /bin/bash -c 'bundle exec rake assets:precompile' webapp
`/home/webapp` is not a directory.
Bundler will use `/tmp/bundler/home/webapp' as your home directory temporarily.
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'rb-readline'.
Gem Load Error is: HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory
Backtrace for gem load error is:
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rb-readline-0.5.5/lib/rbreadline.rb:1097:in `<module:RbReadline>'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rb-readline-0.5.5/lib/rbreadline.rb:17:in `<top (required)>'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rb-readline-0.5.5/lib/readline.rb:10:in `<module:Readline>'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rb-readline-0.5.5/lib/readline.rb:8:in `<top (required)>'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rb-readline-0.5.5/lib/rb-readline.rb:16:in `<top (required)>'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:82:in `require'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:82:in `block (2 levels) in require'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:77:in `each'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:77:in `block in require'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:66:in `each'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:66:in `require'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler.rb:108:in `require'
/var/app/ondeck/config/application.rb:7:in `<top (required)>'
/var/app/ondeck/Rakefile:5:in `require'
/var/app/ondeck/Rakefile:5:in `<top (required)>'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load_rakefile'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:689:in `raw_load_rakefile'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:94:in `block in load_rakefile'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:93:in `load_rakefile'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:77:in `block in run'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/rake-11.1.2/bin/rake:33:in `<top (required)>'
/opt/rubies/ruby-2.3.4/bin/rake:22:in `load'
/opt/rubies/ruby-2.3.4/bin/rake:22:in `<top (required)>'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/cli/exec.rb:74:in `load'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/cli/exec.rb:74:in `kernel_load'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/cli/exec.rb:27:in `run'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/cli.rb:360:in `exec'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/cli.rb:20:in `dispatch'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/cli.rb:10:in `start'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/exe/bundle:35:in `block in <top (required)>'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/opt/rubies/ruby-2.3.4/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/exe/bundle:27:in `<top (required)>'
/opt/rubies/ruby-2.3.4/bin/bundle:22:in `load'
/opt/rubies/ruby-2.3.4/bin/bundle:22:in `<main>'
Bundler Error Backtrace:
/var/app/ondeck/config/application.rb:7:in `<top (required)>'
/var/app/ondeck/Rakefile:5:in `require'
/var/app/ondeck/Rakefile:5:in `<top (required)>'
/opt/rubies/ruby-2.3.4/bin/bundle:22:in `load'
/opt/rubies/ruby-2.3.4/bin/bundle:22:in `<main>'
HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory
/var/app/ondeck/config/application.rb:7:in `<top (required)>'
/var/app/ondeck/Rakefile:5:in `require'
/var/app/ondeck/Rakefile:5:in `<top (required)>'
/opt/rubies/ruby-2.3.4/bin/bundle:22:in `load'
/opt/rubies/ruby-2.3.4/bin/bundle:22:in `<main>'
(See full trace by running task with --trace) (Executor::NonZeroExitStatus)
[2018-03-08T21:21:50.587Z] INFO [2045] - [Application update 2018-03-02-1047-retry-0307@28/AppDeployStage0/AppDeployPreHook/11_asset_compilation.sh] : Activity failed.
[2018-03-08T21:21:50.587Z] INFO [2045] - [Application update 2018-03-02-1047-retry-0307@28/AppDeployStage0/AppDeployPreHook] : Activity failed.
[2018-03-08T21:21:50.587Z] INFO [2045] - [Application update 2018-03-02-1047-retry-0307@28/AppDeployStage0] : Activity failed.
[2018-03-08T21:21:50.587Z] INFO [2045] - [Application update 2018-03-02-1047-retry-0307@28] : Completed activity. Result:
Application update - Command CMD-AppDeploy failed
[2018-03-08T21:30:11.781Z] INFO [2654] - [CMD-TailLogs] : Starting activity...
[2018-03-08T21:30:11.781Z] INFO [2654] - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2018-03-08T21:30:11.781Z] INFO [2654] - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2018-03-08T21:30:11.781Z] INFO [2654] - [CMD-TailLogs/TailLogs] : Starting activity...
[2018-03-08T21:30:11.781Z] INFO [2654] - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...
当我登录到 EC2 实例时,我可以验证 $HOME 是否按预期设置,但我仍然得到上述结果。我假设我遇到的问题可能是应用程序是在某些 chrooted 配置中启动的,而我选择的目录不存在?或者也许我需要使用带有“:”字符的“路径语法”?
但是在这里反复试验需要很长时间,每次尝试我都会通过仪表板重新下载。所以如果有人有更确定的东西,我真的很感激。
【问题讨论】:
问题似乎不是$HOME
是否设置; /home/webapp
根本不存在
这似乎是合理的。不过,我不知道那是从哪里来的。看起来它正在尝试预编译资产,但我在部署之前就这样做了。我刚刚验证了我正在下载的 zip 文件也有资产。我不确定会发生什么变化。
【参考方案1】:
好吧,我已经解决了这个问题。我从我的构建中消除了 rbreadline gem。这是造成问题的原因。我必须解决另一个问题才能做到这一点,首先我查看了rails console doesn't load due to libreadline
然而给出的解决方案,
ln -s /usr/local/opt/readline/lib/libreadline.dylib \
/usr/local/opt/readline/lib/libreadline.6.dylib
没用。对我有用的是
ln -s /usr/local/opt/readline/lib/libreadline.dylib \
/usr/local/opt/readline/lib/libreadline.6.2.dylib
【讨论】:
以上是关于即使设置了 HOME 变量,Bundler 也会死机的主要内容,如果未能解决你的问题,请参考以下文章
即使 EnableSessionState="ReadOnly" 也会设置 asp.net 变量
设置“EDITOR”或“BUNDLER_EDITOR”环境变量
您想告诉我为啥即使我将 bundler 更新为“2.2.21”,Gemfile.lock 中的 bundler 版本仍然是“2.2.16”吗?
为啥即使我修改了 lock 变量,我也会得到一个无限的 while 循环? [复制]