when executing: cap production deploy:initial
I get an error message:
** Execute deploy:assets:precompile
00:08 deploy:assets:precompile
/usr/local/rvm/bin/rvm default do bundle exec rake assets:precompile
rake aborted!
LoadError: cannot load such file -- single_test/tasks
/home/deploy/apps/A_W_Creamery/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:i…
It seems like, you previously have installed Single test gem and now you remove it, but you forgot to remove command:
require 'single_test/tasks'
from your Rakefile.
Okay,
I'm running into some weird issue with our deployment no longer working anymore. I cannot track everything that changed, but I'm hoping someone can help me out with debugging this issue and find out what is going wrong.
deploy.rb
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'app_name'
set :repo_url, 'github_url'
set :deploy_to, '/home/user/path'
# Source Control Configuration
set :scm, :git
# Produces: Please enter the name of the branch. (develop):
set(:branch, ask('the name of the branch.', 'develop'))
# Ask whether we want to perform a backup.
# Produces: Please enter whether to perform a backup of the database? (Y):
set(:backup, ask('whether to perform a backup of the database?', 'Y'))
puts("setting branch to: #{fetch(:branch)}")
set :user, 'my_user'
set :assets_roles, [:web, :app, :vm]
set :keep_assets, 2
set :linked_files, fetch(:linked_files, []).push('.chamber.pem', 'Procfile', '.env')
set :linked_dirs, fetch(:linked_dirs, []).push('data', 'tmp', 'log', 'uploads')
set :keep_releases, 10
set :bundle_path, nil
set :bundle_binstubs, nil
set :bundle_flags, '--system'
set :rvm1_map_bins, fetch(:rvm1_map_bins, []).push('honeybadger')
# Slack integration options
set :slack_via_slackbot, Settings.slack.via_slackbot
set :slack_team, Settings.slack.team
set :slack_token, Settings.slack.token
set :slack_icon_emoji, -> { Settings.slack.icon_emoji }
set :slack_channel, -> { Settings.slack.channel }
set :slack_username, -> { Settings.slack.username }
set :slack_run_starting, -> { Settings.slack.run_starting }
set :slack_run_finished, -> { Settings.slack.run_finished }
set :slack_run_failed, -> { Settings.slack.run_failed }
set :slack_msg_finished, -> { "#channel #{ENV['USER'] || ENV['USERNAME']} has deployed branch *#{fetch :branch}* of #{fetch :application} to *#{fetch :rails_env}*." }
set :slack_msg_failed, -> { "#{ENV['USER'] || ENV['USERNAME']} failed to deploy branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}." }
# Rake config
SSHKit.config.command_map[:rake] = 'bundle exec rake'
before 'deploy:started', 'deploy:rm:stop'
after 'deploy:rm:stop', 'deploy:rm:backup'
after 'deploy:finished', 'deploy:rm:start'
after 'deploy:migrate', 'deploy:rm:seed
Capfile
# Load DSL and set up stages
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'rvm1/capistrano3' # Do not use capistrano/bundler
require 'whenever/capistrano'
require 'capistrano/honeybadger'
require 'slackistrano/capistrano'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
require 'net/ssh/proxy/command'
def vm(tunnel:, tunnel_user: fetch(:user), vm_user: fetch(:user))
server "#{fetch(:stage)}-vm01", {
roles: [:vm],
# The user on the VM
user: vm_user,
ssh_options: {
# The user on the machine we're tunneling through
proxy: Net::SSH::Proxy::Command.new("ssh #{tunnel_user}##{tunnel} -W %h:%p"),
}
}
end
So I can run the cap command locally, and it does part of the work. Had some issues first with the new sprockets, but now it's complaining about the following when it needs to precompile the assets:
INFO [21eca199] Running bundle exec rake assets:precompile as riskmethods#playground.riskmethods.net DEBUG [21eca199] Command: cd /home/riskmethods/riskmethods/releases/20160212152030 && ( export RAILS_ENV="playground" ; bundle exec rake assets:precompile )
DEBUG [2eac7a5b] Finished in 0.078 seconds with exit status 0 (successful).
INFO [4b29f0c4] Running bundle exec rake assets:precompile as riskmethods#playground-vm01
DEBUG [4b29f0c4] Command: cd /home/riskmethods/riskmethods/releases/20160212152030 && ( export RAILS_ENV="playground" ; bundle exec rake assets:precompile )
DEBUG [21eca199] bash: bundle: command not found
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as riskmethods#playground.riskmethods.net: rake exit status: 127
rake stdout: Nothing written
rake stderr: bash: bundle: command not found
SSHKit::Command::Failed:
rake exit status: 127
rake stdout: Nothing written
rake stderr: bash: bundle: command not found
Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error:
Exception while executing as riskmethods#playground.riskmethods.net:
rake exit status: 127
rake stdout: Nothing written
rake stderr: bash: bundle: command not found
DEBUG [4b29f0c4] bash: bundle: command not found
As your error message saying bash: bundle: command not found
It seems you dont have the gem bundler installed on the server
install bundler gem on server by running the following command that should do the trick
gem install bundler
I'm using capistrano 3.2.1 with capistrano-resque gem to restart rasque workers on deployment. Always getting this error.
If I start workers manually under current directory on production server it starts fine.
cd /home/azureuser/apps/app_production/current && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.1 /usr/bin/env nohup RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.1 ~/.rbenv/bin/rbenv exec bundle exec rake RACK_ENV=production RAILS_ENV=production QUEUE="mailer" PIDFILE=/home/azureuser/apps/app_production/shared/tmp/pids/resque_work_1.pid BACKGROUND=yes VERBOSE=1 INTERVAL=5 environment resque:work >> log/resque.log 2>> log/resque.log )
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as azureuser#thesend.cloudapp.net: nohup exit status: 127
nohup stdout: Nothing written
nohup stderr: Nothing written
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:16:in `rescue in block (2 levels) in execute'
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
SSHKit::Command::Failed: nohup exit status: 127
After I worked out that capistrano-rbenv was the problem, I removed that gem from my gemfile and also my capfile.
I then just added the following to my deploy.rb file:
set :default_env, {
PATH: "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH",
RBENV_ROOT: '~/.rbenv',
RBENV_VERSION: '2.2.2'
}
Now capistrano-resque works correctly as does unicorn etc..
I fix this based on the #archfish recommendation on capistrano-resque incompatibility between capistrano-resque and capistrano-rbenv issue. Then you should add or modify the :rbenv_prefix on deploy.rb, like:
set :rbenv_prefix, "env RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
Note: the :rbenv_prefix usually is used like:
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
I need to make it to make my jQuery working on Heroku.
Here is my console:
$ rake assets:precompile
c:/Ruby192/bin/ruby.exe c:/Ruby192/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
Access denied for user 'root'#'localhost' (using password: NO)
Tasks: TOP => environment
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [c:/Ruby192/bin/ruby.exe c:/Ruby192/bin/rak...]
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
When I try do run:
$ assets:precompile
sh: assets:precompile: command not found
EDITED:
Also I added this line to application.rb:
config.assets.initialize_on_precompile = false
You have mentioned wrong username and password of mysql. Some gems which need database access for assets:precompile.
I'm deploying my Rails 3.2.2, Ruby 1.9.3 app with Capistrano to a Linux server. When I'm running a cap deploy I get this error:
* executing `deploy:assets:precompile'
* executing "cd /var/www/production/releases/20120418090209 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["example.com"]
[example.com] executing command
[example.com] sh -c 'cd /var/www/production/releases/20120418090209 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'
** [out :: example.com] rake aborted!
** [out :: example.com] cannot load such file -- ruby-debug
** [out :: example.com]
** [out :: example.com] (See full trace by running task with --trace)
command finished in 8962ms
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/production/releases/20120418090209; true"
servers: ["example.com"]
[example.com] executing command
[example.com] sh -c 'rm -rf /var/www/production/releases/20120418090209; true'
command finished in 176ms
failed: "sh -c 'cd /var/www/production/releases/20120418090209 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on example.com
It says, that the ruby-debug gem was not found. But ruby-debug is not inside the production group in my Gemfile:
group :development, :test do
gem "steak"
gem "linecache19", :git => "git://github.com/mark-moseley/linecache", :require => "ruby-debug"
gem "ruby-debug-base19x", "~> 0.11.30.pre4"
gem "ruby-debug19"
gem "rails_best_practices"
gem "ruby_parser"
gem "reek"
gem "flog"
gem "jslint_on_rails", :git => "git://github.com/psionides/jslint_on_rails"
gem "jasmine-rails"
end
Cause the error gets thrown after the rake assets:precompile command, I think it has something todo with Capistrano and the load 'deploy/assets' call inside my Capfile:
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['config/deploy/recipes/*.rb','vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
When I remove this line, everything deploys fine, but (of course) the assets aren't found in production. And, if I run bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile directly on the server (inside the app dir) I get the same error.
So what should I do?
ruby-debug is obsolete. In ruby >= 1.9 you should use excellent debugger gem
see: https://github.com/cldwalker/debugger and http://railscasts.com/episodes/54-debugging-ruby-revised