No exception received from Rake task with Airbrake rails integration - ruby-on-rails-4

Since version 5 Airbrake and its Rails integration offers automatic exception reporting in any Rake tasks.
However I've not received rake exception on my errbit server.
I've made the following test :
Create a fresh rails 4.1 application.
Include airbrake gem.
Create Airbrake initializer (used an errbit configuration).
Add a rake task which raises an exception.
Gemfile
source 'https://rubygems.org'
gem 'rails', '4.1.6'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'airbrake', '5.0.5'
initializers/airbrake.rb
Airbrake.configure do |config|
config.environment = Rails.env
config.host = 'https://xxxxxxxxxx.herokuapp.com/'
config.project_id = true
config.project_key = 'xxxxxxxxxxx'
config.ignore_environments = []
end
lib/rake/raise.rake
namespace :raise do
desc 'raise error'
task error: :environment do
1 / 0
end
end
I tried to execute the rake task rake raise:error and got the following backtrace:
rake aborted!
ZeroDivisionError: divided by 0
/Users/Yann/code/airbraker/lib/tasks/raise.rake:4:in `/'
/Users/Yann/code/airbraker/lib/tasks/raise.rake:4:in `block (2 levels) in <top (required)>'
/Users/Yann/.gem/ruby/2.2.2/gems/airbrake-5.0.5/lib/airbrake/rake/task_ext.rb:19:in `execute'
Tasks: TOP => raise:error
(See full trace by running task with --trace)
And never received any exception on my errbit server.
Note: execute rake airbrake:test sends an exception to my errbit server, I assume my configuration is correct.
Am I missing something ?

This is a minor bug. The problem is that Airbrake tries to be asynchronous and sometimes it doesn't work as expected. In this particular case the Ruby process quits before Airbrake sends your exception.
I've submitted a patch, which should fix this issue: https://github.com/airbrake/airbrake/pull/513

Related

Bundler:GemNotFound error even though gem is locally installed

In my application, I am using a cron job to execute a simple model method.
A few gems were required for this task.
I installed a gem by including it in the gemfile and running the command
bundle install
Now when I run the server, I get the following error:
/home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find mime-types-data-3.2016.0221 in any of the sources (Bundler::GemNotFound)
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/spec_set.rb:85:in `map!'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/spec_set.rb:85:in `materialize'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/definition.rb:140:in `specs'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/definition.rb:185:in `specs_for'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/definition.rb:174:in `requested_specs'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/environment.rb:18:in `requested_specs'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/runtime.rb:13:in `setup'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler.rb:127:in `setup'
from /home/aditya9509/.rvm/gems/ruby-1.9.3-p551/gems/bundler-1.10.5/lib/bundler/setup.rb:18:in `<top (required)>'
from /home/aditya9509/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/aditya9509/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/aditya9509/Desktop/rubystack-2.0.0-33/projects/cricketStockExchange/config/boot.rb:3:in `<top (required)>'
from bin/rails:8:in `require_relative'
from bin/rails:8:in `<main>'
It says that the bundler was not able to locate mime-types-data-3.2016.0221 gem in any of the sources. To check, I ran the following command which gives a list of locally installed gems related to mime:
gem list | grep "mime"
This gave the following output:
mime-types (3.0, 2.99, 2.6.2)
mime-types-data (3.2016.0221)
Clearly the mime-types-data-3.2016.0221 is installed locally but bundler is not able to find it. Is there any fix to this. Below is my Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.3.18'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'whenever', :require => false
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
gem 'mime-types-data','~> 3.2016.0221'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
I am not sure as to what more information would be appropriate so let me know, I will update my question as needed.
Thanks!
Does the issue persist when running the server with bundle exec rails s?

error with puma in local server

I recently added puma to my app for better performance on heroku. my app works well in production (live) environment but I am getting and error in my local environment..
error when I try to start my server:
Art West#ARTWESTIV ~/desktop/drinkPGH (master)
$ rails s
=> Booting Puma
=> Rails 4.1.8 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
[11868] *** SIGUSR2 not implemented, signal based restart unavailable!
[11868] *** SIGUSR1 not implemented, signal based restart unavailable!
[11868] *** SIGHUP not implemented, signal based logs reopening unavailable!
[11868] Puma starting in cluster mode...
[11868] * Version 3.0.2 (ruby 2.1.5-p273), codename: Plethora of Penguin Pinatas
[11868] * Min threads: 5, max threads: 5
[11868] * Environment: development
[11868] * Process workers: 2
[11868] * Preloading application
[11868] * Listening on tcp://0.0.0.0:3000
Exiting
c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/puma-3.0.2/lib/puma/cluster.rb:320:in `trap': unsupported signal SIGCHLD (ArgumentError)
from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/puma-3.0.2/lib/puma/cluster.rb:320:in `setup_signals'
from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/puma-3.0.2/lib/puma/cluster.rb:389:in `run'
from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/puma-3.0.2/lib/puma/launcher.rb:173:in `run'
from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/puma-3.0.2/lib/rack/handler/puma.rb:51:in `run'
from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.5/lib/rack/server.rb:264:in `start'
from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/commands/server.rb:69:in `start'
from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:81:in `block in server'
from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:in `tap'
from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:in `server'
from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.8/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
and my gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use sqlite3 as the database for Active Record
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bootstrap-sass'
group :production do
gem 'pg'
gem 'rails_12factor'
gem 'puma'
end
group :development, :test do
gem 'sqlite3'
end
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]
my config.puma
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection
end
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
(Not a fix) by commenting line 1 of config/puma.rb, I was able to run puma in development.
or
workers Integer(ENV['WEB_CONCURRENCY'] || 0) also works
Not positive this will solve your problem. I usually run the app locally using foreman. The puma documentation for rails suggests starting your local server like this:
rails s Puma
For what it's worth.

Could not find ruby-oci8, when deploying Rails application using Bundler

Not sure how to go about debugging this error. Deployment of this Rails application is successful on the development server but I get bundle stdout: Could not find ruby-oci8-2.2.0 in any of the sources (error) when deploying to the production server.
Is the error message saying that it can't find ruby-oci8 in the gemset? Any ideas on how I might go about debugging why the deployment isn't working on the production server?
I am using the below Capistrano Gems
capistrano (3.4.0)
capistrano-bundler (1.1.4)
capistrano-file-permissions (0.1.1)
capistrano-rails (1.1.3)
capistrano-rvm (0.1.2)
Shortened message from running: cap production deploy
** Invoke deploy:updated (first_time)
** Invoke bundler:install (first_time)
** Execute bundler:install
DEBUG [103a4281] Running /usr/bin/env if test ! -d /home/rails/apps/cals_db_sync/releases/20151020160801; then echo "Directory does not exist '/home/rails/apps/cals_db_sync/releases/20151020160801'" 1>&2; false; fi as deploy_user#example.com
DEBUG [103a4281] Command: if test ! -d /home/rails/apps/cals_db_sync/releases/20151020160801; then echo "Directory does not exist '/home/rails/apps/cals_db_sync/releases/20151020160801'" 1>&2; false; fi
DEBUG [103a4281] Finished in 0.006 seconds with exit status 0 (successful).
INFO [60676e5b] Running /usr/local/rvm/bin/rvm ruby-2.1.6#cals_db_sync do bundle install --path /home/rails/apps/cals_db_sync/shared/bundle --without development test --deployment --quiet as deploy_user#example.com
DEBUG [60676e5b] Command: cd /home/rails/apps/cals_db_sync/releases/20151020160801 && ( RVM_BIN_PATH=/usr/local/rvm/bin /usr/local/rvm/bin/rvm ruby-2.1.6#cals_db_sync do bundle install --path /home/rails/apps/cals_db_sync/shared/bundle --without development test --deployment --quiet )
DEBUG [60676e5b] Could not find ruby-oci8-2.2.0 in any of the sources
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy_user#example.com: bundle exit status: 7
bundle stdout: Could not find ruby-oci8-2.2.0 in any of the sources
bundle stderr: Nothing written
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:16:in `rescue in block (2 levels) in execute'
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
SSHKit::Command::Failed: bundle exit status: 7
bundle stdout: Could not find ruby-oci8-2.2.0 in any of the sources
bundle stderr: Nothing written
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/sshkit-1.7.1/lib/sshkit/command.rb:95:in `exit_status='
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:179:in `block in _execute'
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:133:in `tap'
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:133:in `_execute'
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:66:in `execute'
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/capistrano-bundler-1.1.4/lib/capistrano/tasks/bundler.cap:35:in `block (5 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/sshkit-1.7.1/lib/sshkit/backends/abstract.rb:85:in `with'
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/capistrano-bundler-1.1.4/lib/capistrano/tasks/bundler.cap:26:in `block (4 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/sshkit-1.7.1/lib/sshkit/backends/abstract.rb:77:in `within'
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/capistrano-bundler-1.1.4/lib/capistrano/tasks/bundler.cap:25:in `block (3 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `run'
/usr/local/rvm/gems/ruby-2.1.6#cals_db_sync/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => deploy:updated => bundler:install
The deploy has failed with an error: Exception while executing as deploy_user#example.com: bundle exit status: 7
bundle stdout: Could not find ruby-oci8-2.2.0 in any of the sources
bundle stderr: Nothing written
** Invoke deploy:failed (first_time)
** Execute deploy:failed
Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
gem 'exception_notification'
# Use mysql as the database for Active Record
gem 'mysql2', '0.3.20' # Of 9/2015, the '0.4.*' is BUGGY and BREAKS!
# Build Tabless Models
gem "activerecord-tableless" # , "~> 1.0"
# Due to upgrading this Rails 3 app to Rails 4, needed the below gem to work with
# Rails 4 Mass Assignment Security. (Rails 3 handled Mass Assignment security via Models)
gem 'protected_attributes'
# Using the "Chamber" gem to address Rails 4's "Secret Key Base"
# Install?
# 1- bundle
# 2- add to your project via "$ chamber init"
# a. creates a public key called .chamber.pem.pub
# b. creates a protected key called .chamber.pem.enc
# c. creates a private key called .chamber.pem
# d. adds the protected and private keys to your .gitignore file so they aren't accidentally checked in
# e. creates a settings.yml file to get you started
# Note: Keep the private key safe since anyone who has it will be able to decrypt any settings that Chamber encrypts for you.
gem 'chamber'
# Installed and currently using
# hashie 3.4.2
# chamber 2.8.0
# Whenver Gem needed for Cron Jobs
# run: wheneverize (dot) # or wheneverize . ... use after bundle to setup Whenever
# See whenever output in console by: bundle exec whenever
gem 'whenever', require: false # set to false b/c don't want to use directly within Rails App
gem 'ruby-oci8'
gem 'activerecord-oracle_enhanced-adapter', '~> 1.6.0'
# Rails 4.0 & 4.1 => '~> 1.5.0'
# Rails 4.2 => '~> 1.6.0'
# Not needed yet ... Add ability to database table field comments when migrating
#gem 'migration_comments'
# Add settingslogic to App for Global variables
# it's a simple configuration / settings solution that uses an ERB enabled YAML file.
gem 'settingslogic'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.2'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use debugger
# gem 'debugger', group: [:development, :test]
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :test do
gem 'rspec-rails' # rails generate rspec:install
gem 'shoulda'
gem 'shoulda-matchers'
gem 'capybara'
#gem 'selenium-webdriver'
gem 'factory_girl_rails'
gem 'database_cleaner'
end
group :development do
gem 'rspec-rails' # rspec in dev so the rake tasks run properly
gem 'factory_girl_rails'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug' # for Ruby 2
# Deploy with Capistrano
# Setting as of 07/2015
gem 'capistrano', '~> 3.1' # , require: false # is using -v 3.4.0
gem 'capistrano-rails', '~> 1.1' # , require: false
gem 'capistrano-bundler', '~> 1.1.2'
gem 'capistrano-rvm'
gem 'capistrano-file-permissions'
# $ bundle
# $ cap install
end
It would sound like you have the Oracle Ruby gem in a development block. It would help if you posted your Gemfile.
I reverted the ruby-oci8 gem back to version 2.1.7 in the Gemfile instead of using the latest version of 2.2.0. And the deployment (bundle install) through Capistrano worked. On the Ubuntu servers I am using Oracle Instant Client and SDK version 11.2.0.3.0
After the successful deployment, I looked on the production server at the installed gems, the ruby-oci8 gem had a datestamp of this past February (when it was last installed) so I am curious if the ruby-oci8 had not previously existed and needed to be installed if the "bundle install" would work ...

How to setup puppet-rspec correctly?

I'm following the instructions from here
gem install rvm
gem install bundle
# Demo dir
# Gemfile
source "https://rubygems.org"
gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet', '~> 3.7.5'
gem 'rspec-puppet-facts'
# spec_helper.rb
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
include RspecPuppetFacts
Now when I run bundle exec rake spec I get the following error:
/usr/bin/ruby -I/usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib:/usr/lib/ruby/gems/1.8/gems/rspec-support-3.3.0/lib /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/exe/rspec --pattern spec/\{classes,defines,unit,functions,hosts,integration\}/\*\*/\*_spec.rb --color
Total resources: 0
Touched resources: 0
Resource coverage: -nan%
Untouched resources:
/usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/hooks.rb:516:in `all_hooks_for': return from proc-closure (LocalJumpError)
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/hooks.rb:568:in `process'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/flat_map.rb:12:in `map'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/flat_map.rb:12:in `flat_map'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/hooks.rb:567:in `process'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/hooks.rb:433:in `register_globals'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/example_group.rb:395:in `set_it_up'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/example_group.rb:362:in `subclass'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/example_group.rb:254:in `describe'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/dsl.rb:43:in `__send__'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/dsl.rb:43:in `describe'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/dsl.rb:82:in `__send__'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/dsl.rb:82:in `describe'
from /etc/puppet/modules/demo/spec/classes/example_spec.rb:3
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1327:in `load'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1327:in `load_spec_files'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1325:in `each'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1325:in `load_spec_files'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:102:in `setup'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:88:in `run'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:73:in `run'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:41:in `invoke'
from /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/exe/rspec:4
/usr/bin/ruby -I/usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/lib:/usr/lib/ruby/gems/1.8/gems/rspec-support-3.3.0/lib /usr/lib64/ruby/gems/1.8/gems/rspec-core-3.3.1/exe/rspec --pattern spec/\{classes,defines,unit,functions,hosts,integration\}/\*\*/\*_spec.rb --color failed
Any thoughts on how I can resolve this? Or can someone provide some clear instructions on how can go about getting this to work on a CentOS 6.5 machine?
Updating the Gemfile to the following and running bundle update worked:
source 'https://rubygems.org'
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', '3.7.5'
end
gem 'metadata-json-lint'
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
gem 'rspec-puppet-facts'
# rspec must be v2 for ruby 1.8.7
if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9'
gem 'rspec', '~> 2.0'
end

Prawn in a Ruby on Rails app, failing on production

I am stuck on an issue with running prawn in production.
I have followed the Railscast (revised http://railscasts.com/episodes/153-pdfs-with-prawn-revised?view=asciicast) pretty much to the letter. It works great in my development environment (Mac OS X 10.9.1) but causes unicorn to falter on my server. My production server is (Redhat => Red Hat Enterprise Linux Server release 6.4 (Santiago)). I have the gem installed via Gemfile.
Gemfile:
gem 'prawn'
gem 'prawn-qrcode'
Controller: (show action)
def show
##classroom = Classroom.find(params[:id])
#classroom = find_classroom
#page_title = #classroom.location.name
#classroom_alt = #classroom.location.name + " - " + #classroom.room_number
#building = find_building(#classroom.location_id)
#owner = Owner.find(#classroom.owner_id)
#room_schedule_contact = RoomScheduleContact.find_by rmrecnbr:(#classroom.rmrecnbr)
#building_image = #building.picture.url(:medium).to_s
#building_sign_image = #building.building_sign.url(:thumb).to_s
#search = Classroom.search(params[:search])
##classroom_herprod = Building.find(params[:location_id]).building_short_code
respond_to do |format|
format.html # show.html.erb
format.png { render :qrcode => "http://rooms.lsa.umich.edu/classrooms/#{#classroom.facility_code_heprod}", :level => :l, :unit => 8 }
format.pdf do
pdf = ClassroomPdf.new(#classroom)
send_data pdf.render, type: "application/pdf",
disposition: "inline"
end
end
end
I have a pdfs directory with a classroom_pdf.rb file that includes the following.
class ClassroomPdf < Prawn::Document
def initialize(classroom)
super(top_margin: 70)
text "This is a pdf"
end
end
(This is stripped down from what I had, but it is the most basic version that works on my dev system and fails on production).
I am running the following
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
gem 'rails', '4.0.2'
The error in the unicorn.stderr.log is as follows.
E, [2014-02-07T12:39:20.400750 #7300] ERROR -- : reaped #<Process::Status: pid 7306 exit 1> worker=1
I, [2014-02-07T12:39:20.401257 #7300] INFO -- : worker=1 spawning...
I, [2014-02-07T12:39:20.463964 #7529] INFO -- : worker=1 spawned pid=7529
I, [2014-02-07T12:39:20.521524 #7529] INFO -- : Refreshing Gem list
E, [2014-02-07T12:39:29.938423 #7326] ERROR -- : uninitialized constant Prawn (NameError)
/var/www/rooms.lsa.umich.edu/html/iris/releases/20140207173433/app/pdfs/classroom_pdf.rb:1:in `<top (required)>'
/var/www/rooms.lsa.umich.edu/html/iris/shared/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
Here is the gemfile
source 'https://rubygems.org'
##gem 'rails', '3.2.14'
gem 'rails', '4.0.2'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
#gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
gem "haml"
#gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails'
gem 'bootstrap-sass', '~> 3.1.0'
#gem 'google-analytics-rails'
gem 'font-awesome-rails'
gem 'protected_attributes'
gem 'modernizr-rails'
gem "jquery-rails"
gem "devise", "3.0.3"
gem "cancan", ">= 1.6.9"
gem "rolify", ">= 3.2.0"
gem 'newrelic_rpm'
# QR-Code generation
gem 'rqrcode-rails3'
gem 'mini_magick'
gem 'prawn'
#gem 'prawn', '1.0.0.rc2'
gem 'prawn-qrcode'
#gem 'prawnto'
gem 'capistrano', '2.15.5'
#gem 'capistrano'
gem "simple_form"
gem 'will_paginate', '~> 3.0.5'
gem "therubyracer", :group => :assets, :platform => :ruby
gem 'will_paginate-bootstrap'
#gem 'kaminari'
## Used for uploading and resizing images (Need both paperclip and mini_magick)
gem "paperclip", "3.5.1"
#gem "meta_search"
gem "ransack"
gem 'annotate', ">=2.6.0"
group :production do
gem 'unicorn'
end
Any ideas?
It turns out that I needed to manually reboot unicorn for it to properly load the new gem file.