【问题标题】:Bundler fails for deploying using elastic beanstalkBundler 无法使用弹性 beantalk 进行部署
【发布时间】:2014-09-03 16:00:26
【问题描述】:

尝试使用弹性 beanstalk 在 ec2 上部署 rails 4.2.1 应用程序时出现以下错误

on't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Fetching source index from https://rubygems.org/
Fetching git@github.com:bokmann/font-awesome-rails.git
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Retrying git clone 'git@github.com:bokmann/font-awesome-rails.git' "/var/app/ondeck/vendor/bundle/ruby/2.0/cache/bundler/git/font-awesome-rails-aa9211906101215f2656ef38ba0c26146ba4c6bc" --bare --no-hardlinks --quiet due to error (2/3): Bundler::Source::Git::GitCommandError Git error: command `git clone 'git@github.com:bokmann/font-awesome-rails.git' "/var/app/ondeck/vendor/bundle/ruby/2.0/cache/bundler/git/font-awesome-rails-aa9211906101215f2656ef38ba0c26146ba4c6bc" --bare --no-hardlinks --quiet` in directory /var/app/ondeck has failed.
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Git error: command `git clone 'git@github.com:bokmann/font-awesome-rails.git'
"/var/app/ondeck/vendor/bundle/ruby/2.0/cache/bundler/git/font-awesome-rails-aa9211906101215f2656ef38ba0c26146ba4c6bc"
--bare --no-hardlinks --quiet` in directory /var/app/ondeck has failed.

2014-07-13 15:16:48,672 [ERROR] (4743 MainThread) [directoryHooksExecutor.py-33] [root directoryHooksExecutor error] Script  /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed with returncode 11

.ebextensions/ruby.config 看起来像这样

# Install git in order to be able to bundle gems from git
packages:
yum:
git: []
patch: []

commands:
# Run rake with bundle exec to be sure you get the right version
add_bundle_exec:
test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
cwd: /opt/elasticbeanstalk/hooks/appdeploy/pre
command: perl -pi -e 's/(rake)/bundle exec $1/' 11_asset_compilation.sh 12_db_migration.sh
# Bundle with --deployment as recommended by bundler docs
#   cf. http://gembundler.com/v1.2/rationale.html under Deploying Your Application
add_deployment_flag:
test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
cwd: /opt/elasticbeanstalk/hooks/appdeploy/pre
command: perl -pi -e 's/(bundle install)/$1 --deployment/' 10_bundle_install.sh
# Vendor gems to a persistent directory for speedy subsequent bundling
make_vendor_bundle_dir:
test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
command: mkdir /var/app/support/vendor_bundle
# Store the location of vendored gems in a handy env var
set_vendor_bundle_var:
test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
cwd: /opt/elasticbeanstalk/support
command: sed -i '12iexport  
EB_CONFIG_APP_VENDOR_BUNDLE=$EB_CONFIG_APP_SUPPORT/vendor_bundle' envvars
# The --deployment flag tells bundler to install gems to vendor/bundle/, so
# symlink that to the persistent directory
symlink_vendor_bundle:
test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
cwd: /opt/elasticbeanstalk/hooks/appdeploy/pre
command: sed -i 's/\(^cd $EB_CONFIG_APP_ONDECK\)/\1\nln -s $EB_CONFIG_APP_VENDOR_BUNDLE .\/vendor\/bundle/' 10_bundle_install.sh
# Don't run the above commands again on this instance
#   cf. http://stackoverflow.com/a/16846429/283398
z_write_post_provisioning_complete_file:
cwd: /opt/elasticbeanstalk/support
command: touch .post-provisioning-complete%

我正在使用 64 位 Amazon Linux 服务器并尝试使用 ruby-2.0.0passenger 进行安装

【问题讨论】:

    标签: ruby-on-rails amazon-web-services amazon-elastic-beanstalk


    【解决方案1】:

    我怀疑这是失败的,因为在您的 ebextensions 中您正在运行 bundle install --deployment。您是否有理由要使用 --deployment 标志。看看这个答案:https://stackoverflow.com/a/3681411/161628。 如果您的用例不需要 --deployment 标志,我建议不要使用它。

    您可以使用供应商/缓存使用this 博客中记录的方法在本地打包您的应用依赖项。

    您能否使用 Gemfile 的内容更新问题。您是否在 Gemfile 中使用 git@ URL?如果您的 Gemfile 中有“git@github.com:bokmann/font-awesome-rails.git”,您可能需要使用“git://github.com:bokmann/font-awesome-rails.git”之类的 URL . 看看this的答案。

    【讨论】:

    • 没有特别的理由使用 --deployment flat。我删除了它。再次测试
    • 那么什么最终奏效了?删除部署标志或更改 git url?
    • 我也有同样的问题。问题是我有一个参考相对路径的宝石。你能帮我解决一下吗? gem 'pushmeup', :path=>'vendor/pushmeup'
    猜你喜欢
    • 2014-10-21
    • 2017-12-18
    • 2019-04-14
    • 1970-01-01
    • 2017-01-13
    • 2016-02-26
    • 2016-11-29
    • 2016-01-11
    • 2020-11-27
    相关资源
    最近更新 更多