I built a rails application that I want to deploy to elastic beanstalk. I was able to deploy it to my AWS account but now I want to deploy it to my clients account. For some reason it I get errors when trying to deploy it. Have been able to deploy it to my account from scratch and been able to deploy it to heroku but every time I try to deploy it to my clients account I get a bunch of errors. Are there possible settings that would be different between the two accounts? I don't understand why deploying to the two accounts would be any different. I have tried every solution I could find.
Here are the logs. I am not sure if they will help
gem 'bootstrap-sass'
gem 'autoprefixer-rails'
gem 'puma'
group :development, :test do
gem "letter_opener"
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
group :production do
# gem 'pg'
gem 'rails_12factor'
end
+ '[' -d /var/app/ondeck/vendor/cache ']'
+ bundle install
Don'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.
Warning: the running version of Bundler is older than the version that created the lockfile. We sugg
est you upgrade to the latest version of Bundler by running `gem install bundler`.
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Fetching dependency metadata from https://rubygems.org/
Using rake 11.1.2
Using i18n 0.7.0
Installing json 1.8.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-1pc5aw8.rb extconf.rb
Cannot allocate memory - /opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-1pc5aw8.rb extcon
f.rb 2>&1
Gem files will remain installed in /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/json-1.8.3 for in
spection.
Results logged to /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0-static/js
on-1.8.3/gem_make.out
Using minitest 5.9.0
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.1.0
Using pkg-config 1.1.7
Using rack 1.6.4
Using mime-types-data 3.2016.0521
Using arel 6.0.3
Using execjs 2.7.0
Installing bcrypt 3.1.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-myt7e8.rb extconf.rb
Cannot allocate memory - /opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-myt7e8.rb extconf.rb 2>&1
Gem files will remain installed in /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/bcrypt-3.1.10 for inspection.
Results logged to /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0-static/bcrypt-3.1.10/gem_make.out
Using sass 3.4.22
Using coffee-script-source 1.10.0
Using thor 0.19.1
Using concurrent-ruby 1.0.2
Using multi_json 1.12.1
Using libv8 3.16.14.15
Installing puma 3.4.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-kv1g4s.rb extconf.rb
Cannot allocate memory - /opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-kv1g4s.rb extconf.rb 2>&1
Gem files will remain installed in /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/puma-3.4.0 for inspection.
Results logged to /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0-static/puma-3.4.0/gem_make.out
Using bundler 1.12.1
Using rails_serve_static_assets 0.0.5
Using rails_stdout_logging 0.0.4
Using ref 2.0.0
Using tilt 2.0.5
Installing sqlite3 1.3.11 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-5lnc3v.rb extconf.rb
Cannot allocate memory - /opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-5lnc3v.rb extconf.rb 2>&1
Gem files will remain installed in /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.11 for inspection.
Results logged to /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0-static/sqlite3-1.3.11/gem_make.out
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling. (Executor::NonZeroExitStatus)
[2016-07-08T19:47:55.300Z] INFO [424] - [Application update app-d3f5-160708_124551#2/AppDeployStage0/AppDeployPreHook/10_bundle_install.sh] : Activity failed.
[2016-07-08T19:47:55.301Z] INFO [424] - [Application update app-d3f5-160708_124551#2/AppDeployStage0/AppDeployPreHook] : Activity failed.
[2016-07-08T19:47:55.301Z] INFO [424] - [Application update app-d3f5-160708_124551#2/AppDeployStage0] : Activity failed.
[2016-07-08T19:47:55.302Z] INFO [424] - [Application update app-d3f5-160708_124551#2] : Completed activity. Result:
Application update - Command CMD-AppDeploy failed
[2016-07-08T20:17:06.267Z] INFO [1271] - [CMD-TailLogs] : Starting activity...
[2016-07-08T20:17:06.268Z] INFO [1271] - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2016-07-08T20:17:06.268Z] INFO [1271] - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2016-07-08T20:17:06.268Z] INFO [1271] - [CMD-TailLogs/TailLogs] : Starting activity...
[2016-07-08T20:17:06.268Z] INFO [1271] - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...
I found that the answer from #osazemeu based on the blog article needed a tweak, because the container_commands execute too late (after the application was already set up), and thus it was never run.
I changed the container_command into a command (see this AWS documentation for detail on the difference between the two), and also created the file inline rather than having a separate .sh file since I didnt want to have to keep track of what directory that was being put in at deployment time. I called the file 01setup_swap.config and placed in the directory .ebextensions in the root of my project. This did the trick for me. The contents is as follows:
files:
"/home/ec2-user/setup_swap.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
# based on http://steinn.org/post/elasticbeanstalk-swap/
SWAPFILE=/var/swapfile
SWAP_MEGABYTES=2048
if [ -f $SWAPFILE ]; then
echo "Swapfile $SWAPFILE found, assuming already setup"
exit;
fi
/bin/dd if=/dev/zero of=$SWAPFILE bs=1M count=$SWAP_MEGABYTES
/bin/chmod 600 $SWAPFILE
/sbin/mkswap $SWAPFILE
/sbin/swapon $SWAPFILE
commands:
01setup_swap:
command: "bash setup_swap.sh"
cwd: "/home/ec2-user/"
Just ran in to this error. Here is what I learned and how I got passed this issue:
With the free tier of AWS elastic beanstalk, by default the EC2 instance type you get, as of the date of this answer, is t1.micro. t1.micro has a very small amount of memory. So little that the gem install process for this gem fails as it is evident by the post. t1.micro is now considered a previous generation instance type (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html). To get past this memory allocation failure, you must update the EC2 instance of your AWS elastic beanstalk app from t1.micro to t2.micro. This worked for me.
I encountered similar issues a couple of days back and this was how I solved it. Only proceed to the next step if the present step fails.
Step 1:
Increase the swap memory of your ElasticBean EC2 instance
yourapp/.ebextensions/setup_swap.sh
#!/bin/bash
SWAPFILE=/var/swapfile
SWAP_MEGABYTES=2048
if [ -f $SWAPFILE ]; then
echo "Swapfile $SWAPFILE found, assuming already setup"
exit;
/bin/dd if=/dev/zero of=$SWAPFILE bs=1M count=$SWAP_MEGABYTES
/bin/chmod 600 $SWAPFILE
/sbin/mkswap $SWAPFILE
/sbin/swapon $SWAPFILE
Step 1.1 In your yourapp/.ebextensions/01_setup_swap.config
container_commands:
01setup_swap:
command: "bash .ebextensions/swap/setup_swap.sh"
source: elasticbeanstalk-swap
Step 2:
Increase the size of your ElasticBeanstalk instance, and try to deploy again.
Step 3:
If all else fails, run this command in your rails app.
bundle exec bundle package
This compiles the gems and saves it to a local folder (vendor/cache) in your rails app. This folder is accessed during deployment, and there will be no for compilation.
Commit these files to your repo, and attempt to deploy. It should work without hitches.
Related
I decided to start a rails project. I went to the terminal and as usual typed in rails new blog. Instead of it completing I got this error
Installing nio4r 2.3.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/nio4r-2.3.1/ext/nio4r
C:/Ruby23-x64/bin/ruby.exe -r ./siteconf20181001-1392-69sdrh.rb extconf.rb
current directory: C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/nio4r-2.3.1/ext/nio4r
make "DESTDIR=" clean
'make' is not recognized as an internal or external command,
operable program or batch file.
current directory: C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/nio4r-2.3.1/ext/nio4r
make "DESTDIR="
'make' is not recognized as an internal or external command,
operable program or batch file.
make failed, exit code 1
Gem files will remain installed in
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/nio4r-2.3.1 for inspection.
Results logged to
C:/Ruby23-x64/lib/ruby/gems/2.3.0/extensions/x64-mingw32/2.3.0/nio4r-2.3.1/gem_make.out
An error occurred while installing nio4r (2.3.1), and Bundler cannot continue.
Make sure that gem install nio4r -v '2.3.1' --source 'https://rubygems.org/'
succeeds before bundling.
In Gemfile:
rails was resolved to 5.2.1, which depends on
actioncable was resolved to 5.2.1, which depends on
nio4r
Now I did install the gem file nio4r version 2.3.1 and it installed successfully. but I still received the same error message. I do not know what is causing this.
Okay, so I'm very new to Rails, and am just beginning to feel my way around my new Linux operating system as well.
I'm currently doing a project for school, and I've followed all of the directions to perfection. For consistency purposes, they want specific versions of both rails and gemsets.
After I have initialized rails in my directory, I then run a
bundle install command, and have several installation issues which I are in the code block as follows:
user#user-ThinkPad-T430 ~/code/bloccit $ sudo bundle install
[sudo] password for user:
Don'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 gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies.....
Using rake 12.3.0
Using concurrent-ruby 1.0.5
Installing json 1.8.6 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/json-
1.8.6/ext/json/ext/generator
/usr/bin/ruby2.3 -r ./siteconf20171128-11271-1ah858h.rb extconf.rb
mkmf.rb can't find header files for ruby at
/usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/json-1.8.6
for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-
linux/2.3.0/json-1.8.6/gem_make.out
Using minitest 5.10.3
Using thread_safe 0.3.6
Using builder 3.2.3
Using erubis 2.7.0
Using mini_portile2 2.3.0
Using crass 1.0.3
Using rack 1.6.8
Using mini_mime 1.0.0
Using arel 6.0.4
Using bundler 1.11.2
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using thor 0.20.0
Installing ffi 1.9.18 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/ffi-1.9.18/ext/ffi_c
/usr/bin/ruby2.3 -r ./siteconf20171128-11271-1382ks7.rb extconf.rb
mkmf.rb can't find header files for ruby at
/usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/ffi-1.9.18
for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-
linux/2.3.0/ffi-1.9.18/gem_make.out
Installing pg 0.21.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/pg-0.21.0/ext
/usr/bin/ruby2.3 -r ./siteconf20171128-11271-171n79p.rb extconf.rb
mkmf.rb can't find header files for ruby at
/usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/pg-0.21.0
for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-
linux/2.3.0/pg-0.21.0/gem_make.out
Using rb-fsevent 0.10.2
Using tilt 2.0.8
Installing sqlite3 1.3.13 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3
/usr/bin/ruby2.3 -r ./siteconf20171128-11271-ml1ggl.rb extconf.rb
mkmf.rb can't find header files for ruby at
/usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/sqlite3-
1.3.13 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-
linux/2.3.0/sqlite3-1.3.13/gem_make.out
Using turbolinks-source 5.0.3
Using i18n 0.9.1
An error occurred while installing json (1.8.6), and Bundler cannot
continue.
Make sure that `gem install json -v '1.8.6'` succeeds before bundling.
The main error seems to be the Gem::Ext::BuildError: ERROR: Failed to build gem native extension. line, but it's also having problems installing json within the bundler.
Any helpful advice or tips would be appreciated!
First of all follow the instruction (please avoid sudo):
Don'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.
To resolve this issue in linux, run:
sudo apt install ruby2.3-dev
Cheers!
I use the mina to deploy a rails web app,but always have many error.
This is part of my mina's logs
Using mini_magick (4.5.1)
Installing pg (0.18.4)
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/www/sample_app/shared/bundle/ruby/2.3.0/gems/pg-0.18.4/ext
/usr/bin/ruby2.3 -r ./siteconf20160917-1997-acaacj.rb extconf.rb
Cannot allocate memory - /usr/bin/ruby2.3 -r ./siteconf20160917-1997-acaacj.rb extconf.rb 2>&1
Gem files will remain installed in /var/www/sample_app/tmp/build-14740431655892/vendor/bundle/ruby/2.3.0/gems/pg-0.18.4 for inspection.
Results logged to /var/www/sample_app/tmp/build-14740431655892/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/pg-0.18.4/gem_make.out
An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.
! ERROR: Deploy failed.
-----> Cleaning up build
Unlinking current
OK
Connection to IP closed.
! Command failed.
Failed with status 1 (4864)
I noticed Cannot allocate memory but I use top keep watch on the memory,only use about 50%(total 1G),and I am already run gem install pg -v '0.18.4',install pg succeed. I can use gem listfind it.
How to fix it?Thanks
I am just getting started with ruby on rails, after installing rails executing many commands on the console, i tried to run rails server with the command rails server but gets an error about not loading coffee-rails, i tried the command gem install coffee-rails i got
gem install coffee-rails
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing coffee-rails:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe -r ./siteconf20140724-4244-v083ym.rb extconf.rb
creating Makefile
make clean
Makefile:165: *** target pattern contains no `%'. Stop.
make
Makefile:165: *** target pattern contains no `%'. Stop.
make failed, exit code 2
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.
1 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/extensions/x86-mingw32/1.9.1/js
on-1.8.1/gem_make.out
RubyGems 2.4.1 will not build native extensions in Ruby version 1.9.3 and earlier on Windows.
You will need to downgrade RubyGems to 1.8.29.
To do this run the following command:
gem update --system 1.8.29
Check gem version:
gem -v
1.8.29
Now try your command again:
gem install coffee-rails
ref: https://groups.google.com/forum/#!topic/rubyinstaller/k19SeJijpKU/discussion
Take a look at this answer - they seem to have had the same trouble and had to use an older version of make.
I'm just getting into ruby on rails, And I'm setting it up on a second windows computer.
I've used the most recent 'railsinstaller' using rails: 4.0.0 and ruby: 2.0.0p195
when I run rails new <project name> Rails creates the project but fails on the bundle step with the following error.
Installing atomic (1.1.14)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
D:/RailsInstaller/Ruby2.0.0/bin/ruby.exe extconf.rb
creating Makefile
Gem files will remain installed in D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/atomic-1.1.14 for inspection.
Results logged to D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/atomic-1.1.14/ext/gem_make.out
An error occurred while installing atomic (1.1.14), and Bundler cannot continue.
Make sure that `gem install atomic -v '1.1.14'` succeeds before bundling.
I've tried a few things I've found on google such as updating gem and ruby but none of that worked... I'm too new to rails to figure this out myself, does anyone know what might be the problem?
EDIT
the outcome of gem install atomic -v '1.1.14'
D:\Programming\Ruby>gem install atomic -v '1.1.14'
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ConEmu blocks ANSICON injection
The system cannot find the file D:\ansicon\ansicon-master\ansicon.exe.
ERROR: Error installing atomic:
ERROR: Failed to build gem native extension.
D:/RailsInstaller/Ruby2.0.0/bin/ruby.exe extconf.rb
creating Makefile
Gem files will remain installed in D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/atomic-1.1.14 for inspection.
Results logged to D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/atomic-1.1.14/ext/gem_make.out
Thanks,
Peter McKinney