Repository: capistrano/capistrano

Issue #1552: Stage not set, please close my previous issue 
Created: 2016-01-04T22:01:34Z
I fixed the previous error by adding <require 'capistrano/setup'. Sorry I did not want to you to waste time helping me with an issue I resolved. THX I have this, any suggestions would be great! My AWS account seems to be setup properly. The error is the next 5 lines. Ruby 2.1.7, Capistrano Version: 3.4.0 (Rake Version: 10.4.2), using latest Github "rubber" gem. Rails 4.2.3.
new-host:capistrano waynemattingly$ cap rubber:create_staging --trace
** Invoke ensure_stage (first_time)
** Execute ensure_stage
Stage not set, please call something such as cap production deploy, where production is a stage you have defined.
CAPFILE:
gemfile = File.expand_path(File.join(FILE, '..', 'Gemfile'))
if File.exist?(gemfile) && ENV['BUNDLE_GEMFILE'].nil?
puts "Respawning with 'bundle exec'"
exec("bundle", "exec", "cap", *ARGV)
end
TODO load deploy not working with cap version 3
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
load  'deploy'
env = ENV['RUBBER_ENV'] ||= (ENV['RAILS_ENV'] || 'production')
root = File.dirname(FILE)
this tries first as a rails plugin then as a gem
$:.unshift "#{root}/vendor/plugins/rubber/lib/"
require 'rubber'
require 'bundler'
require 'capistrano'
require 'capistrano/setup'
Rubber::initialize(root, env)
DEPLOY.RB:
This is a sample Capistrano config file for rubber
TODO all the requires were added to this default file generated by cap
require 'rubber'
require 'capistrano'
require 'bundler/capistrano'
require 'config/deploy'
Rubber::initialize(root, env)
require 'rubber/capistrano'
require 'capistrano/setup'
set :rails_env, Rubber.env
TODO two different clues for setting stage and line was added to default code [set :stage, :production]
set :stage, :production
on :load do
#TODO changed from set :application, rubber_env.app_name
set :application, rubber_env.trilinkfinancial
set :runner,      rubber_env.app_user
set :deploy_to,   "/mnt/#{application}-#{Rubber.env}"
set :copy_exclude, [".git/", ".bundle/", "log/*", ".rvmrc", ".rbenv-version"]
set :assets_role, [:app]
end
TODO code line added to file via web-help 142016
set :linked_files, %w{config/database.yml}
Use a simple directory tree copy here to make demo easier.
You probably want to use your own repository for a real app
set :scm, :none
set :repository, "."
set :deploy_via, :copy
Easier to do system level config as root - probably should do it through
sudo in the future.  We use ssh keys for access, so no passwd needed
set :user, 'root'
set :password, nil
Use sudo with user rails for cap deploy:[stop|start|restart]
This way exposed services (mongrel) aren't running as a privileged user
set :use_sudo, true
If you're having troubles connecting to your server, uncommenting this
line will give you more verbose logging output from net-ssh, which will
make debugging the problem much easier.
set :ssh_log_level, :debug
How many old releases should be kept around when running "cleanup" task
set :keep_releases, 3
Lets us work with staging instances without having to checkin config files
(instance_.yml + rubber_.yml) for a deploy.  This gives us the
convenience of not having to checkin files for staging, as well as
the safety of forcing it to be checked in for production.
set :push_instance_config, Rubber.env != 'production'
don't waste time bundling gems that don't need to be there
set :bundle_without, [:development, :test, :staging] if Rubber.env == 'production'
Allow us to do N hosts at a time for all tasks - useful when trying
to figure out which host in a large set is down:
RUBBER_ENV=production MAX_HOSTS=1 cap invoke COMMAND=hostname
max_hosts = ENV['MAX_HOSTS'].to_i
default_run_options[:max_hosts] = max_hosts if max_hosts > 0
Allows the tasks defined to fail gracefully if there are no hosts for them.
Comment out or use "required_task" for default cap behavior of a hard failure
rubber.allow_optional_tasks(self)
Wrap tasks in the deploy namespace that have roles so that we can use FILTER
with something like a deploy:cold which tries to run deploy:migrate but can't
because we filtered out the :db role
namespace :deploy do
rubber.allow_optional_tasks(self)
tasks.values.each do |t|
if t.options[:roles]
task t.name, t.options, &t.body
end
end
end
namespace :deploy do
namespace :assets do
rubber.allow_optional_tasks(self)
tasks.values.each do |t|
if t.options[:roles]
task t.name, t.options, &t.body
end
end
end
end
load in the deploy scripts installed by vulcanize for each rubber module
Dir["#{File.dirname(FILE)}/rubber/deploy-*.rb"].sort.each do |deploy_file|
load deploy_file
end
capistrano's deploy:cleanup doesn't play well with FILTER
after "deploy", "cleanup"
after "deploy:migrations", "cleanup"
task :cleanup, :except => { :no_release => true } do
count = fetch(:keep_releases, 5).to_i
rsudo <<-CMD
all=$(ls -x1 #{releases_path} | sort -n);
keep=$(ls -x1 #{releases_path} | sort -n | tail -n #{count});
remove=$(comm -23 <(echo -e "$all") <(echo -e "$keep"));
for r in $remove; do rm -rf #{releases_path}/$r; done;
CMD
end
We need to ensure that rubber:config runs before asset precompilation in Rails, as Rails tries to boot the environment,
which means needing to have DB access.  However, if rubber:config hasn't run yet, then the DB config will not have
been generated yet.  Rails will fail to boot, asset precompilation will fail to complete, and the deploy will abort.
if Rubber::Util.has_asset_pipeline?
#TODO wayne 132016 load deploy not part of cap version 3 may need to re-enable
#load 'deploy/assets'
callbacks[:after].delete_if {|c| c.source == "deploy:assets:precompile"}
callbacks[:before].delete_if {|c| c.source == "deploy:assets:symlink"}
before "deploy:assets:precompile", "deploy:assets:symlink"
after "rubber:config", "deploy:assets:precompile"
end

Duplicate issue #1551: undefined local variable or method `tasks_without_stage_dependency' for #<Capistrano::Application
Created: 2016-01-04T21:41:16Z
Hello I have been stuck here for days, I would really appreciate help. I have been to many site uninstalled and re-installed etceteras. Here is my error log. I am using Rails 4.2.3, Ruby 2.1.7-p400, Capistrano Version: 3.4.0 (Rake Version: 10.4.2), and the latest rubber gem. It seems rubber installed without error and bundles work as well as general rake and rails sever.
$cap rubber:create_staging --trace
cap aborted!
NameError: undefined local variable or method `tasks_without_stage_dependency' for #Capistrano::Application:0x007ff5fccf3600
/usr/local/rvm/gems/ruby-2.1.7/gems/capistrano-3.4.0/lib/capistrano/application.rb:57:in top_level_tasks' /usr/local/rvm/gems/ruby-2.1.7/gems/rake-10.4.2/lib/rake/application.rb:106:inblock in top_level'
/usr/local/rvm/gems/ruby-2.1.7/gems/rake-10.4.2/lib/rake/application.rb:115:in run_with_threads' /usr/local/rvm/gems/ruby-2.1.7/gems/rake-10.4.2/lib/rake/application.rb:100:intop_level'
/usr/local/rvm/gems/ruby-2.1.7/gems/rake-10.4.2/lib/rake/application.rb:78:in block in run' /usr/local/rvm/gems/ruby-2.1.7/gems/rake-10.4.2/lib/rake/application.rb:176:instandard_exception_handling'
/usr/local/rvm/gems/ruby-2.1.7/gems/rake-10.4.2/lib/rake/application.rb:75:in run' /usr/local/rvm/gems/ruby-2.1.7/gems/capistrano-3.4.0/lib/capistrano/application.rb:15:inrun'
/usr/local/rvm/gems/ruby-2.1.7/gems/capistrano-3.4.0/bin/cap:3:in <top (required)>' /usr/local/rvm/gems/ruby-2.1.7/bin/cap:23:inload'
/usr/local/rvm/gems/ruby-2.1.7/bin/cap:23:in ' /usr/local/rvm/gems/ruby-2.1.7/bin/ruby_executable_hooks:15:ineval'
/usr/local/rvm/gems/ruby-2.1.7/bin/ruby_executable_hooks:15:in `

Closing comment (2016-01-05T04:36:19Z): Duplicate of #1552