有弹性的Beanstalk Ruby/Rails需要安装git,所以bundle安装工作。但不

时间:2022-08-25 09:01:25

I'm having an issue deploying our rails app.. I created a hook like the example on the AWS blog howto http://ruby.awsblog.com/post/Tx2AK2MFX0QHRIO/Deploying-Ruby-Applications-to-AWS-Elastic-Beanstalk-with-Git like:

我有一个问题要部署我们的rails应用。我创建了一个钩子,就像AWS博客上的例子一样:http://ruby.awsblog.com/post/tx2ak2mfx0qhrio/deploying-ruby-applications-toaws-- with-git:

packages:
  yum:
    git: []

even I run a bundle package to create vendor/cache to have all the gems there... and still getting: git://github.com/refinery/refinerycms-search.git (at 2-0-stable) is not checked out. Please run bundle install (Bundler::GitError)

甚至我运行一个包包来创建供应商/缓存来拥有所有的gem……仍然得到:git:// github.com/refinerycms-search.git(在2-0稳定值)没有检出。请运行bundle install (Bundler: GitError)

any help will be nice, we trying to move all our apps to EB. but seens that git does not install or something is going on.. I need git on the EB ec2 instance it creates.

任何帮助都会很好,我们试着把所有的应用程序转移到EB上。但是看到git没有安装或者发生了一些事情。我需要在它创建的EB ec2实例上使用git。

StackTrace:

加:

Error message:
git://github.com/refinery/refinerycms-search.git (at 2-0-stable) is not checked out.         Please run `bundle install` (Bundler::GitError)
Exception class:
PhusionPassenger::UnknownError
Application root:
/var/app/current
Backtrace:
#   File    Line    Location
0   /usr/share/ruby/1.9/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/source.rb 801 in        `rescue in load_spec_files'
1   /usr/share/ruby/1.9/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/source.rb 799 in   `load_spec_files'
2   /usr/share/ruby/1.9/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/source.rb 381 in `local_specs'
3   /usr/share/ruby/1.9/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/source.rb 774 in `specs'
4   /usr/share/ruby/1.9/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/definition.rb 174 in `block in resolve'
5   /usr/share/ruby/1.9/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/definition.rb 172 in `each'
6   /usr/share/ruby/1.9/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/definition.rb 172 in `resolve' 
7   /usr/share/ruby/1.9/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/definition.rb 113 in `specs'
8   /usr/share/ruby/1.9/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/definition.rb 158 in `specs_for'
9   /usr/share/ruby/1.9/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/definition.rb 147 in `requested_specs'
10  /usr/share/ruby/1.9/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/environment.rb    23  in `requested_specs'
11  /usr/share/ruby/1.9/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/runtime.rb    11   in `setup'
12  /usr/share/ruby/1.9/gems/1.9.1/gems/bundler-1.2.1/lib/bundler.rb    116 in `setup'
13  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/utils.rb    326 in `prepare_app_process'
14  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/rack/application_spawner.rb 156 in `block in initialize_server'
15  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/utils.rb    563 in `report_app_init_status'
16  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/rack/application_spawner.rb 154 in `initialize_server'
17  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-  1002/support/lib/phusion_passenger/abstract_server.rb    204 in `start_synchronously'
18  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/abstract_server.rb  180 in `start'
19  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/rack/application_spawner.rb 129 in `start'
20  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/spawn_manager_orig.rb   253 in `block (2 levels) in spawn_rack_application'
21  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/abstract_server_collection.rb   132 in `lookup_or_add'
22  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/spawn_manager_orig.rb   246 in `block in spawn_rack_application'
23  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/abstract_server_collection.rb   82  in `block in synchronize'
24      prelude>    10:in `synchronize'
25  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/abstract_server_collection.rb   79  in `synchronize'
26  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/spawn_manager_orig.rb   244 in `spawn_rack_application'
27  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/spawn_manager_orig.rb   137 in `spawn_application'
28  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/spawn_manager.rb    16  in `spawn_application_with_env'
29  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/spawn_manager_orig.rb   275 in `handle_spawn_application'
30  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/abstract_server.rb  357 in `server_main_loop'
31  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/lib/phusion_passenger/abstract_server.rb  206 in `start_synchronously'
32  /var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.4.6-1002/support/helper-scripts/passenger-spawn-server

UPDATE more info: I decided to log into the instance with ec2-user and notice that git is installed the gems I need ARE installed so far I can see.. when I do bundle list they all show up even the one that the error is complaining about.. I do notice that when I do a general gem list then it DOES not show up... but it should be using the bundle one.

更新更多信息:我决定用ec2-user登录实例,注意到git已经安装好了,我需要的gem到目前为止都已经安装好了。当我做bundle list的时候,它们都显示出来,即使是错误的抱怨。我确实注意到,当我做一个一般的宝石列表时,它不会出现……但是它应该使用bundle 1。

5 个解决方案

#1


46  

(Note that the following workaround should only be used if you must use Git sources for dependencies. It is recommended not to install dependencies from external Git repositories if it can be avoided. See below for details on why that is.)

(注意,只有当您必须使用Git源代码作为依赖项时,才应该使用以下变通方法。如果可以避免,建议不要安装外部Git存储库的依赖项。详情请见下文。

When using Git backed libraries in a Gemfile with Passenger, you must disable shared gems in an installation (in addition to installing Git in the hook you listed above). You can do this by setting the BUNDLE_DISABLE_SHARED_GEMS Bundler environment variable in your existing .ebextensions/ruby.config file like so:

当您在Gemfile中使用Git支持的库时,您必须在安装中禁用共享gem(除了在上面列出的钩子中安装Git之外)。您可以在现有的. ebextense /ruby中设置BUNDLE_DISABLE_SHARED_GEMS Bundler环境变量。配置文件如下所示:

option_settings:
  - option_name: BUNDLE_DISABLE_SHARED_GEMS
    value: "1"
  - option_name: BUNDLE_PATH
    value: "vendor/bundle"

packages:
  yum:
    git: []

Disabling shared gems will force all dependencies to be vendored into your application in vendor/bundle as specified by the BUNDLE_PATH variable.

禁用共享gems将强制所有依赖项在供应商/bundle中放入应用程序,如BUNDLE_PATH变量所指定。

Note that, whenever possible, you should avoid installing public libraries from Git sources with your application. Using Git for library locations introduces another point of failure for a deployment install, since the Git repository may be temporarily unavailable or even permanently moved. Also keep in mind that forcing vendored installs in a deployment will cause your Elastic Beanstalk deployments to be much slower on subsequent deploys of an app with the same dependencies. This is because the libraries will be re-installed at each deploy instead of taking advantage of the system-wide installation that Elastic Beanstalk has Bundler perform by default.

请注意,在可能的情况下,您应该避免使用您的应用程序在Git源代码中安装公共库。对于库位置使用Git会为部署安装引入另一个失败点,因为Git存储库可能暂时不可用,甚至永久移动。还要记住,在部署中强制安装自动售货机将导致您的弹性Beanstalk部署在具有相同依赖关系的应用程序的后续部署时要慢得多。这是因为库将在每次部署时重新安装,而不是利用Elastic Beanstalk默认执行的全系统安装。

In short, if there is an official RubyGem release of the library in question, you should use that version instead; and if not, you should suggest to the library author that an official RubyGem release be made available.

简而言之,如果有关于该库的官方RubyGem版本,您应该使用该版本;如果没有,你应该建议图书馆的作者提供一个正式的RubyGem版本。

FYI a similar question about this Git problem with regular Passenger/Rails deployments was previously asked: Rails 3: Passenger can't find git gems installed by bundler

给大家一个类似的问题,关于常规乘客/轨道部署的Git问题,之前有人问过:Rails 3: Passenger找不到bundler安装的Git gems

#2


10  

Another option is to package the gem source directly with your application and then point bundler at that.

另一种选择是将gem源代码直接打包到应用程序中,然后指向bundler。

Copy the gem source into vendor/gems/mygem

将宝石来源复制到供应商/宝石/mygem中

Then, in your Gemfile:

然后,在你的Gemfile:

gem 'mygem', path: File.join(File.dirname(__FILE__), 'vendor', 'gems', 'mygem')

See more here: http://viget.com/extend/bundler-best-practices

在这里看到更多:http://viget.com/extend/bundler-best-practices

#3


6  

Amazon's Elastic Beanstalk Ruby AMI needs a little tweaking in order to allow you to bundle gems from git without sacrificing deployment speed, behavior you get out of the box with Capistrano and Heroku.

Amazon的弹性Beanstalk Ruby AMI需要稍作调整,以允许您在不牺牲部署速度的情况下将git中的gem打包在一起,您可以使用Capistrano和Heroku进行配置。

Fortunately, the Elastic Beanstalk configuration API makes the necessary tweaks possible without requiring you to maintain a custom AMI.

幸运的是,弹性Beanstalk配置API使必要的调整成为可能,而无需维护自定义AMI。

Here's the Elastic Beanstalk configuration that I use to get the desired, conventional Ruby deployment behavior with Amazon's own AMI: https://github.com/gkop/elastic-beanstalk-ruby .

下面是我使用的弹性Beanstalk配置,用于通过Amazon自己的AMI获得所需的常规Ruby部署行为:https://github.com/gkopelasticity - Beanstalk - Ruby。

#4


1  

  • ok well after lot of research and testing I figure this was related to Amazon having some issues with the passenger env values...
  • 经过大量的研究和测试,我认为这与亚马逊在乘客环境价值方面的问题有关。
  • I was able to run manually rails s and then it worked fine and all gems loaded.. but with passenger it did not so find that if I run

    我能够手动运行rails s,然后它工作得很好,并且装载了所有的gem。但是对于乘客来说,如果我跑的话,它就不会发现

    bundle pack --all

    捆包,所有

  • --all so it also packs the git gems..

    ——所有这些也都包了git gems…

  • it will then run like a charm..

    然后它会像咒语一样运行。

  • to be able to have this run in the mean time Amazon fixes this issue with bundle I create a hook and force it to run after every install. not the best way but works.

    为了能够在Amazon用bundle修复这个问题的同时运行,我创建了一个hook,并在每次安装之后强制它运行。这不是最好的方法,但很有效。

Note: using the hook I cant seen to run the command on EB updates so I git add the vendor/cache and it uploads it all by default.

注意:使用我看不到的钩子在EB更新中运行命令,所以我添加了供应商/缓存,并在默认情况下将其全部上载。

#5


1  

After trying the accepted answer, I found that a simpler .ebextensions/ruby.config was the only config that worked:

在尝试了被接受的答案后,我发现一个更简单的ebex/ ruby。配置是唯一有效的配置:

packages:
  yum:
    git: []

#1


46  

(Note that the following workaround should only be used if you must use Git sources for dependencies. It is recommended not to install dependencies from external Git repositories if it can be avoided. See below for details on why that is.)

(注意,只有当您必须使用Git源代码作为依赖项时,才应该使用以下变通方法。如果可以避免,建议不要安装外部Git存储库的依赖项。详情请见下文。

When using Git backed libraries in a Gemfile with Passenger, you must disable shared gems in an installation (in addition to installing Git in the hook you listed above). You can do this by setting the BUNDLE_DISABLE_SHARED_GEMS Bundler environment variable in your existing .ebextensions/ruby.config file like so:

当您在Gemfile中使用Git支持的库时,您必须在安装中禁用共享gem(除了在上面列出的钩子中安装Git之外)。您可以在现有的. ebextense /ruby中设置BUNDLE_DISABLE_SHARED_GEMS Bundler环境变量。配置文件如下所示:

option_settings:
  - option_name: BUNDLE_DISABLE_SHARED_GEMS
    value: "1"
  - option_name: BUNDLE_PATH
    value: "vendor/bundle"

packages:
  yum:
    git: []

Disabling shared gems will force all dependencies to be vendored into your application in vendor/bundle as specified by the BUNDLE_PATH variable.

禁用共享gems将强制所有依赖项在供应商/bundle中放入应用程序,如BUNDLE_PATH变量所指定。

Note that, whenever possible, you should avoid installing public libraries from Git sources with your application. Using Git for library locations introduces another point of failure for a deployment install, since the Git repository may be temporarily unavailable or even permanently moved. Also keep in mind that forcing vendored installs in a deployment will cause your Elastic Beanstalk deployments to be much slower on subsequent deploys of an app with the same dependencies. This is because the libraries will be re-installed at each deploy instead of taking advantage of the system-wide installation that Elastic Beanstalk has Bundler perform by default.

请注意,在可能的情况下,您应该避免使用您的应用程序在Git源代码中安装公共库。对于库位置使用Git会为部署安装引入另一个失败点,因为Git存储库可能暂时不可用,甚至永久移动。还要记住,在部署中强制安装自动售货机将导致您的弹性Beanstalk部署在具有相同依赖关系的应用程序的后续部署时要慢得多。这是因为库将在每次部署时重新安装,而不是利用Elastic Beanstalk默认执行的全系统安装。

In short, if there is an official RubyGem release of the library in question, you should use that version instead; and if not, you should suggest to the library author that an official RubyGem release be made available.

简而言之,如果有关于该库的官方RubyGem版本,您应该使用该版本;如果没有,你应该建议图书馆的作者提供一个正式的RubyGem版本。

FYI a similar question about this Git problem with regular Passenger/Rails deployments was previously asked: Rails 3: Passenger can't find git gems installed by bundler

给大家一个类似的问题,关于常规乘客/轨道部署的Git问题,之前有人问过:Rails 3: Passenger找不到bundler安装的Git gems

#2


10  

Another option is to package the gem source directly with your application and then point bundler at that.

另一种选择是将gem源代码直接打包到应用程序中,然后指向bundler。

Copy the gem source into vendor/gems/mygem

将宝石来源复制到供应商/宝石/mygem中

Then, in your Gemfile:

然后,在你的Gemfile:

gem 'mygem', path: File.join(File.dirname(__FILE__), 'vendor', 'gems', 'mygem')

See more here: http://viget.com/extend/bundler-best-practices

在这里看到更多:http://viget.com/extend/bundler-best-practices

#3


6  

Amazon's Elastic Beanstalk Ruby AMI needs a little tweaking in order to allow you to bundle gems from git without sacrificing deployment speed, behavior you get out of the box with Capistrano and Heroku.

Amazon的弹性Beanstalk Ruby AMI需要稍作调整,以允许您在不牺牲部署速度的情况下将git中的gem打包在一起,您可以使用Capistrano和Heroku进行配置。

Fortunately, the Elastic Beanstalk configuration API makes the necessary tweaks possible without requiring you to maintain a custom AMI.

幸运的是,弹性Beanstalk配置API使必要的调整成为可能,而无需维护自定义AMI。

Here's the Elastic Beanstalk configuration that I use to get the desired, conventional Ruby deployment behavior with Amazon's own AMI: https://github.com/gkop/elastic-beanstalk-ruby .

下面是我使用的弹性Beanstalk配置,用于通过Amazon自己的AMI获得所需的常规Ruby部署行为:https://github.com/gkopelasticity - Beanstalk - Ruby。

#4


1  

  • ok well after lot of research and testing I figure this was related to Amazon having some issues with the passenger env values...
  • 经过大量的研究和测试,我认为这与亚马逊在乘客环境价值方面的问题有关。
  • I was able to run manually rails s and then it worked fine and all gems loaded.. but with passenger it did not so find that if I run

    我能够手动运行rails s,然后它工作得很好,并且装载了所有的gem。但是对于乘客来说,如果我跑的话,它就不会发现

    bundle pack --all

    捆包,所有

  • --all so it also packs the git gems..

    ——所有这些也都包了git gems…

  • it will then run like a charm..

    然后它会像咒语一样运行。

  • to be able to have this run in the mean time Amazon fixes this issue with bundle I create a hook and force it to run after every install. not the best way but works.

    为了能够在Amazon用bundle修复这个问题的同时运行,我创建了一个hook,并在每次安装之后强制它运行。这不是最好的方法,但很有效。

Note: using the hook I cant seen to run the command on EB updates so I git add the vendor/cache and it uploads it all by default.

注意:使用我看不到的钩子在EB更新中运行命令,所以我添加了供应商/缓存,并在默认情况下将其全部上载。

#5


1  

After trying the accepted answer, I found that a simpler .ebextensions/ruby.config was the only config that worked:

在尝试了被接受的答案后,我发现一个更简单的ebex/ ruby。配置是唯一有效的配置:

packages:
  yum:
    git: []