3

我正在使用eb CLI在AWS上安裝我的Rails應用程序。我已經得到了一個測試之前工作,但現在我試圖部署我寫的一些實際的代碼。當我做git aws.push時,更新失敗。 「eb logs」命令顯示捆綁器失敗。AWS Elastic Beanstalk Rails Bundler失敗

我上運行的Ruby 2.1(彪馬)64位Linux的亞馬遜V1.0.0 2014.03

Fetching source index from https://rubygems.org/ 
Using rake (10.3.2) 
Using i18n (0.6.11) 
Using minitest (4.7.5) 
Using multi_json (1.10.1) 
Using thread_safe (0.3.4) 
Using tzinfo (0.3.41) 
Using activesupport (4.0.8) 
Using builder (3.1.4) 
Using erubis (2.7.0) 
Using rack (1.5.2) 
Using rack-test (0.6.2) 
Using actionpack (4.0.8) 
Using mime-types (1.25.1) 
Using polyglot (0.3.5) 
Using treetop (1.4.15) 
Using mail (2.5.4) 
Using actionmailer (4.0.8) 
Using activemodel (4.0.8) 
Using active_model_serializers (0.9.0) 
Using activerecord-deprecated_finders (1.0.3) 
Using arel (4.0.2) 
Using activerecord (4.0.8) 
Using addressable (2.3.6) 
Using execjs (2.2.1) 
Using autoprefixer-rails (3.0.1.20140826) 
Installing bcrypt (3.1.7) 
Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

    /opt/rubies/ruby-2.1.2/bin/ruby extconf.rb 
Cannot allocate memory - /opt/rubies/ruby-2.1.2/bin/ruby extconf.rb 2>&1 

Gem files will remain installed in /opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/bcrypt-3.1.7 for inspection. 
Results logged to /opt/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0-static/bcrypt-3.1.7/gem_make.out 
An error occurred while installing bcrypt (3.1.7), and Bundler cannot continue. 
Make sure that `gem install bcrypt -v '3.1.7'` succeeds before bundling. 

2014-09-03 00:22:36,561 [ERROR] (3331 MainThread) [directoryHooksExecutor.py-33] [root directoryHooksExecutor error] Script /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed with returncode 5 

我不叫我的寶石文件bcrypt無論是運行此。它必須是魔法寶石的依賴。

我試圖使用供應商/緩存技巧的「捆綁軟件包」,但它一直在說AWS上缺少一些寶石。正如你所看到的,我不僅對彈性beanstalk/aws,而且對rails也很新穎,所以我可能只是在做一些完全錯誤的事情。另外,當我在gemfile.lock中刪除bcrypt引用(我肯定會破壞某些東西)時,它只會在(ffi)後面的不同gem上引發相同的錯誤。我確信有很多寶石,如果我一次只能解決一個問題,它最終會拋出錯誤。

回答

1

因此,對於gem install bcrypt -v '3.1.7'需要的C庫可能存在一些依賴關係。您可以使用yum和ebextensions安裝本地依賴項。

您可以使用ebextensions安裝gem install成功所需的yum包。在您的應用程序源中創建一個名爲.ebextensions/01-yum.config的文件,並在其中放入以下內容。

packages: 
    yum: 
    <required-native-dependency>: [] 

這個文件是YAML格式,所以縮進很重要。

瞭解更多關於ebextensions的pacakges節在這裏:

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-packages

+0

謝謝!當我運行一個無法安裝的gem時,我該如何去了解爲本地依賴提供了什麼? – user3339471 2014-09-06 00:26:03

+0

一些實驗將會有所幫助。您可以ssh訪問該實例並查看/ var/log中的日誌。 – 2014-09-06 00:30:20

8

錯誤實際上是通過實例運行內存不足造成運行make時:

Cannot allocate memory - /opt/rubies/ruby-2.1.2/bin/ruby extconf.rb 2>&1 

更可能你正在運行一個微型實例 - 把它碰到一個更大的實例大小,它應該可靠地構建。

Rohit在他的回答中說得很對,因爲缺少系統軟件包通常是導致無法在Elastic Beanstalk中安裝寶石的原因。