error while deploying rails app to ec2 using rubber gem `response_call': Expected(200) <=> Actual(400 Bad Request) (Excon::Errors::BadRequest) - ruby-on-rails-3

when I do cap rubber:create_staging, I am getting the following error when rubber tries to create ec2 instance. Am I missing any configuration setting?
** Creating instance ami-eafa5883/t1.micro/elearn_production_default,elearn_production_web,elearn_production_web_tools,elearn_production_production,elearn_production_apache,elearn_production_app,elearn_production_passenger,elearn_production_collectd,elearn_production_common,elearn_production_monit,elearn_production_db,elearn_production_mysql,elearn_production_mysql_master,elearn_production_elasticsearch,elearn_production_examples,elearn_production_graphite_server,elearn_production_graphite_web,elearn_production_graylog_elasticsearch,elearn_production_graylog_mongodb,elearn_production_mongodb,elearn_production_graylog_server,elearn_production_graylog_web,elearn_production_haproxy/us-east-1b
/Users/svisamsetty/.rvm/gems/ruby-1.9.3-p429/gems/excon-0.22.1/lib/excon/middlewares/expects.rb:10:in response_call':
Expected(200) <=> Actual(400 Bad Request) (Excon::Errors::BadRequest)
from /Users/svisamsetty/.rvm/gems/ruby-1.9.3-p429/gems/excon-0.22.1/lib/excon/connection.rb:355:inresponse'

I'm having the same problem. It looks like it is covered as Issue #362 on the Rubber github page:
https://github.com/rubber/rubber/issues/362

I downgraded my excon version from 0.22.01 to 0.21.0
Adding this in the gem file and then bundle, fixed the problem.
gem 'excon', '~> 0.21.0'
I am not aware of the root cause though.

I solved this by updating the fog gem by running:
bundle update fog
Aparently I was very outdated running fog 1.9.0. Now im running 1.23.0 and got to successfully deploy to EC2 by following Rubber's Railscasts (http://railscasts.com/episodes/347-rubber-and-amazon-ec2)
This also updated the following gems to these versions:
fog-core 1.23.0
net-scp 1.2.1
fog-json 1.0.0
List item
inflecto 0.0.2
fog-brightbox 0.1.1
fog-softlayer 0.3.11
ipaddress 0.8.0
mini_portile 0.6.0
Nokogiri depends on libxml2-2.9.0 library so be sure to have that installed
Hope it helps!!

Related

Capybara Webkit Capybara::Webkit::ConnectionError failed to start

I'm using capybara webkit on Ubuntu (14.04 LTS) and I'm getting the following error when trying to use it:
Capybara::Webkit::ConnectionError: /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/bin/webkit_server failed to start.
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/connection.rb:75:in `parse_port'
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/connection.rb:81:in `discover_port'
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/connection.rb:62:in `start_server'
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/connection.rb:25:in `initialize'
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/driver.rb:17:in `new'
I installed QT using:
sudo apt-get install libqt4-dev libqtwebkit-dev libqt5webkit5-dev
Using gem versions: capybara (2.4.4) and capybara-webkit (1.3.1)
The same program works fine on mac (qt installed using homebrew)
Thanks
It has been a long time since this question was asked, but I had the same problem even though I used much more ancient versions of anything. It turned out that webkit needs to be able to connect to some X-Server and this is its reaction if it fails. I ended up installing xvfb and using
xvfb-run --auto-servernum bundle exec rake test
(aliased of course) when running my tests. This is probably less than optimal, but it was good enough for me. Maybe this helps the next person who stumbles across this error.
I beat my head against this all morning. Turns out I had omitted this code from rails_helper.rb :
if ENV['HEADLESS']
require 'headless'
headless = Headless.new
headless.start
at_exit { headless.stop }
end
We use the HEADLESS environment variable to trigger this. Not sure if that's typical or a local convention. Regardless, I needed to add export HEADLESS=1 to .env to fire that off.
I also had to add gem 'headless', '~> 1.0.2' in Gemfile.

rvm using /after_cd_bunlder vs --binstubs. How are these different?

How are the outcome of these two methods different? Why use one over the other? I believe they both end up enabling you to issue 'rake' or 'rspec' without the preceeding 'bundle exec". My guess - with method 1 you only have to do this once, and then on ALL new rails project for the rvm ruby version will automatically have the desired feature ( as explained above)?
Method 1:
rvm get head && rvm reload
chmod +x $rvm_path/hooks/after_cd_bundler
bundle install --binstubs
OR
Method 2:
bundle install --binstubs
If found this documentation, but it did not help me understand which method to use. I looked on http://rvm.io and found intergration/bundler and /workflow/hooks.
The is code for after_cd_bundler (but I cannot post anymore links due to stackoverflow.com limitations on me)
This are not two different methods, this is one method and it is described in more detail here: http://robots.thoughtbot.com/post/15346721484/use-bundlers-binstubs
If you are using RVM then you do not need any of this, using --binstubs requires adding to PATH - which is big security risk if used from project directory, RVM comes with rubygems-bundler gem preinstalled which does the automatic loading of bundler (no need for bundle exec), you can find more details about the gem here: https://github.com/mpapis/rubygems-bundler#readme
I am author of rubygems-bundler and maintainer of RVM.

rails 3 - LoadError (cannot load such file -- zip/zip)

I'm using rubyzip to zip a csv file so uses can download it. This works perfectly in development mode. But when I tried zipping the file on the production server (rackspace) I received the error: LoadError (cannot load such file -- zip/zip). Is it a path issue? Anyone know a fix?
The error is being called in my code on this line: require 'zip/zip'
I've tried the solution from here, but it didn't help.
I fixed this problem by specifying gem version 0.9.9 in Gemfile:
gem 'rubyzip', "~> 0.9.9"
Using rubyzip (1.0.0) caused an error.
When upgrading rubyzip to 1.0.0 change require 'zip/zip' to require 'zip'.
I had this problem after adding roo to a Rails project.
Roo needed the new interface, something else (some other gem) was using the old interface - so most of these answers didn't work (couldn't lower the version of rubyzip, rubyzip2 is deprecated, didn't have require zip/zip in my project).
What worked for me was cassio-s-cabral's answer referring to the rubyzip github page.
gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version
gem 'zip-zip' # will load compatibility for old rubyzip API.
I had the same problem: error thrown on "require 'zip/zip'" code, and the solution from this post also did not help.
After a long research I found that the problem was that my "require 'zip/zip'" statement was done in a separate
lib/exporters/package_exporter.rb
file, and for some reason "require" statements are not handled in "lib" folder in production by default.
When I moved "require 'zip/zip'" to the beginning of my
app/controllers/packages_controller.rb
the problem was solved!
I had a similar issue with active_support, just added the 'zip' gem to my Gemfile and it worked fine
I'm use rubyzip2 gem to fix this problem
gem 'rubyzip2'
what work for me was to install 2 gems:
gem install rubyzip
gem install zip
and in the script put
require 'rubygems'
require 'zip/zip'
In their github page explains what to do.
Rubyzip interface changed!!! No need to do require "zip/zip" and Zip
prefix in class names removed.
If you have issues with any third-party gems what required old
version of rubyzip you can use next workaround:
gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version
gem 'zip-zip' # will load compatibility for old rubyzip API.

undefined method `acts_as_mappable' trying to use geokit

I am trying to use geokit but I get the following message:
undefined method `acts_as_mappable'
I have tried the following solutions but nothing has worked so far:
Rails 3.1.0, geokit, with error acts_as_mappable
I am using rails 3.0.1 and ruby 1.9.2
I have followed the instructions here https://github.com/jlecour/geokit-rails3 but its not working
This is my model:
class Event < ActiveRecord::Base
acts_as_mappable :default_units => :kms,
:default_formula => :flat
end
and I have this in my gemfile
gem 'geokit-rails3'
I also have the folder vendor, inside I have a geokit-rails3 folder with the files, one of them named acts_as_mappable. I have tried adding require 'geokit-rails3' in the top of my model but it says no file to load.
I tried both, installing it as a plugin:
rails plugin install git://github.com/jlecour/geokit-rails3.git
and also by doing gem install (and it is shown when I list all the gems installed)
Any help is greatly appreciated.
The problem was solved by reinstalling rails with:
sudo apt-get install rails rails-doc rails-ruby1.8

Heroku app crashes, logs say "No such file to load -- nokogiri (LoadError)"

I had a working app, added Nokogiri, to parse some xml, runs fine locally.
My Gemfile includes: gem 'nokogiri'
I ran bundle install and verified my Gemfile.lock includes DEPENDENCIES ... nokogiri
In my controller class I added (didnt thinkI had to but got an error locally if I didnt):
class MydealController < ApplicationController
require 'rubygems'
require 'open-uri'
require 'nokogiri'
when I use my browser to get the url in MydealController that uses nokogiri doc = Nokogiri::XML(getresult) Heroku crashes.
heroku logs shows this error No such file to load -- nokogiri (LoadError)
Looking at what happens when I git push heroku I do not see nokogiri on the list of many many gems that get installed. Heroku says the push was fine, but nokogiri is not listed and I get the aforementioned error...
It seems that when using Windows Gemfile.lock will contain version of nokogiri gem specific for windows, solution is to remove Gemfile.lock and push to heroku.
More info on this subject here
Your mission should you choose to accept it.
Ensure:
nokogiri is in Gemfile.lock
Gemfile.lock is committed to git
you push the commit that has nokogiri in Gemfile.lock to Heroku
Good luck! This message will self destruct in 10 seconds...
Just had the same problem -- you have to run bundle install to get it added to the Gemfile.lock which heroku looks at to find uninstalled dependencies.
This might help to understand the reason:
http://devcenter.heroku.com/articles/ps
Indeed removing Gemfile.lock might help. All other compiled gem will cause isseu. Best way is to ask Heroku's support.
Only found this article:
http://ganeshprasadsr.blogspot.com/2010/10/installing-nokogiri-for-rails-3-app-on.html
Try to remove require 'nokogiri' from controller.
It works for me.