ruby-on-rails-4capistrano3airbrake

Airbrake integration with Capistrano 3 with Rails 4 getting LoadError: cannot load such file -- airbrake/capistrano3


So, here is my Capfile

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

# Includes tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
#   https://github.com/capistrano/rvm
#   https://github.com/capistrano/rbenv
#   https://github.com/capistrano/chruby
#   https://github.com/capistrano/bundler
#   https://github.com/capistrano/rails
#
require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'

require 'capistrano/rails/migrations'
require 'capistrano/rails/assets'
require 'airbrake/capistrano3'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

Here's my deploy file:

# config valid only for Capistrano 3.1
lock '3.2.1'

set :application, 'my_app'
set :repo_url, 'git@github.com:org/my-app.git'

# Default branch is :master
set :branch, 'dev'
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call

# Default deploy_to directory is /var/www/my_app
set :deploy_to, '/webapps/my_app'

# Default value for :scm is :git
# set :scm, :git

# Default value for :format is :pretty
# set :format, :pretty

# Default value for :log_level is :debug
# set :log_level, :debug

# Default value for :pty is false
# set :pty, true
set :deploy_via, :remote_cache
# Default value for :linked_files is []
set :linked_files, %w{config/database.yml config/secrets.yml}

set :normalize_asset_timestamps, %{public/images public/javascripts public/stylesheets}

# Default value for linked_dirs is []
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
set :bundle_flags,      "--deployment --verbose"
# Default value for keep_releases is 5
# set :keep_releases, 5
set :ssh_options, { :forward_agent => true }

namespace :deploy do

  desc "Restarting mod_rails with restart.txt"
  task :restart do
    on roles (:app),:except => { :no_release => true } do
      puts "\x1B[35m Restarting ... \x1B[0m"
      execute "touch #{current_path}/tmp/restart.txt"
      puts "\x1B[35m Done. \x1B[0m"
    end
  end

  desc "Tag deployed release"
    task :tag do
    run_locally do
      timestamp = Time.now.strftime("%Y_%m_%d_%H_%M_%S")
      tag_name = "#{fetch(:stage)}_#{timestamp}"
      latest_revision = fetch(:current_revision)
      strategy.git "tag -f #{tag_name} #{latest_revision}"
      strategy.git "push -f --tags"
      info "[cap-deploy-tagger] Tagged #{latest_revision} with #{tag_name}"
    end
  end

  after :publishing, :restart
  after :restart, :cleanup
  after :cleanup, 'deploy:tag'
  #after 'deploy:finished', 'airbrake:deploy'
end

The issue is that when I run "cap production deploy:check" I get:

LoadError: cannot load such file -- airbrake/capistrano3
/home/dir/dev/my-app/Capfile:24:in `require'
/home/dir/dev/my-app/Capfile:24:in `<top (required)>'
/home/dir/.rvm/gems/ruby-2.1.0/gems/capistrano-3.2.1/lib/capistrano/application.rb:15:in `run'
/home/dir/.rvm/gems/ruby-2.1.0/gems/capistrano-3.2.1/bin/cap:3:in `<top (required)>'
/home/dir/.rvm/gems/ruby-2.1.0/bin/cap:23:in `load'
/home/dir/.rvm/gems/ruby-2.1.0/bin/cap:23:in `<main>'
/home/dir/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `eval'
/home/dir/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)

If I change require 'airbrake/capistrano3'to require 'airbrake/capistrano' then I get NoMethodError: undefined methodinstance' for Capistrano::Configuration:Class`

Any ideas on how to fix it?

Thanks a lot!

BTW, here's my gemfile

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'
# Use mysql as the database for Active Record
gem 'mysql2'
# 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

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use debugger
# gem 'debugger', group: [:development, :test]

gem 'haml'
gem 'devise'
gem 'will_paginate', '~> 3.0'
gem 'thin'
gem 'faye'
gem 'aasm'
gem 'useragent'
gem 'mini_magick'
gem 'carrierwave'
gem 'airbrake'

group :development do
  gem 'capistrano-rails'
    gem 'capistrano-bundler'
    gem 'capistrano-rvm'
    gem 'rspec-rails'
    gem 'pry'
end

Solution

  • Are you sure you have Airbrake 4.1.0 installed?