Switchtower - unitialized constant

Just loaded up Switchtower 1.0 today, via gems. I’m on OS X (10.4.5),
with ruby and friends installed via darwinports in opt/local.

After installing ST, I switchtowerized my app, set up the deploy recipe,
then ran:

rake remote_exec ACTION=setup

When I do, i get this error:

rake aborted!
uninitialized constant SwitchTower

Obviously, this happens with any of the tasks in ST (like
show_deploy_tasks). Anyone ran into this before?

On Feb 19, 2006, at 4:39 PM, Brad D. wrote:

rake aborted!
uninitialized constant SwitchTower

Obviously, this happens with any of the tasks in ST (like
show_deploy_tasks). Anyone ran into this before?

What is the output if you run rake with the --trace option?

rake --trace remote_exec ACTION=setup

  • Jamis

Jamis B. wrote:

What is the output if you run rake with the --trace option?

rake --trace remote_exec ACTION=setup

  • Jamis

Ahh, should have put that in the original post…

braddaily$ rake show_deploy_tasks --trace
(in /Users/braddaily/Sites/erails_svn)
** Invoke remote_exec (first_time)
** Execute remote_exec
rake aborted!
uninitialized constant SwitchTower
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:200:in
const_missing' ./lib/tasks/switchtower.rake:21:inswitchtower_invoke’
./lib/tasks/switchtower.rake:51
./lib/tasks/switchtower.rake:45:in call' /opt/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:232:inexecute’
/opt/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:232:in each' /opt/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:232:inexecute’
/opt/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:202:in invoke' /opt/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:195:insynchronize’
/opt/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:195:in invoke' /opt/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:1719:inrun’
/opt/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:1719:in each' /opt/local/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:1719:inrun’
/opt/local/lib/ruby/gems/1.8/gems/rake-0.7.0/bin/rake:7
/opt/local/bin/rake:18:in `load’
/opt/local/bin/rake:18

braddaily$ rake show_deploy_tasks --trace

That trace is actually from

rake remote_exec ACTION=setup --trace

misguided copy and paste :slight_smile:

Brad D. wrote:

braddaily$ rake show_deploy_tasks --trace

That trace is actually from

rake remote_exec ACTION=setup --trace

misguided copy and paste :slight_smile:

I’m still tinkering, here is something interesting:

irb(main):001:0> require ‘rubygems’
=> true
irb(main):002:0> SwitchTower
NameError: uninitialized constant SwitchTower
from (irb):2
irb(main):003:0> require ‘SwitchTower’
=> true
irb(main):004:0> SwitchTower
=> SwitchTower

So, in my switchtower.rake file, I added

require ‘SwitchTower’

right after the rubygems require. Now I get:

uninitialized constant CLI

followed by the exact same trace as before…

Jamis B. wrote:

What does your switchtower.rake look like? Something sounds fishy…

  • Jamis

Indeed, here is the rake file…

=============================================================================

A set of rake tasks for invoking the SwitchTower automation utility.

=============================================================================

Invoke the given actions via SwitchTower

def switchtower_invoke(*actions)
begin
require ‘rubygems’
rescue LoadError
# no rubygems to load, so we fail silently
end

options = actions.last.is_a?(Hash) ? actions.pop : {}

args = %w[-r config/deploy]
verbose = options[:verbose] || “-vvvvv”
args << verbose

args = %w[-vvvvv -r config/deploy]
args.concat(actions.map { |act| ["-a", act.to_s] }.flatten)
SwitchTower::CLI.new(args).execute!
end

desc “Push the latest revision into production”
task :deploy do
switchtower_invoke :deploy
end

desc “Rollback to the release before the current release in production”
task :rollback do
switchtower_invoke :rollback
end

desc “Describe the differences between HEAD and the last production
release”
task :diff_from_last_deploy do
switchtower_invoke :diff_from_last_deploy
end

desc “Enumerate all available deployment tasks”
task :show_deploy_tasks do
switchtower_invoke :show_tasks, :verbose => “”
end

desc “Execute a specific action using switchtower”
task :remote_exec do
unless ENV[‘ACTION’]
raise “Please specify an action (or comma separated list of actions)
via the ACTION environment variable”
end

actions = ENV[‘ACTION’].split(",")
switchtower_invoke(*actions)
end

On Feb 19, 2006, at 6:24 PM, Brad D. wrote:

So, in my switchtower.rake file, I added

require ‘SwitchTower’

right after the rubygems require. Now I get:

uninitialized constant CLI

followed by the exact same trace as before…

What does your switchtower.rake look like? Something sounds fishy…

  • Jamis

What does your switchtower.rake look like? Something sounds fishy…

  • Jamis

mine is identical, i even deleted it and re-ran

switchtower --apply-to …

-felix

Ok, think I got it. I downgraded to 0.10.0 and found this line:

require ‘switchtower/cli’

that is not in the switchtower.rake file in ST 1.0. I added that line
and all is well with 1.0!

So, I changed this:

begin
require ‘rubygems’
rescue LoadError
# no rubygems to load, so we fail silently
end

options = actions.last.is_a?(Hash) ? actions.pop : {}

— to:

begin
require ‘rubygems’
rescue LoadError
# no rubygems to load, so we fail silently
end

require ‘switchtower/cli’

options = actions.last.is_a?(Hash) ? actions.pop : {}

Yup, good catch, Brad. That’s my fault. When I “fixed” the
switchtower_invoke task to be more configurable, I accidentally
deleted that line. I’ll fix that and package another release asap.

In the meantime, doing as Brad suggested below will correct the
problem for anyone else running into this.

  • Jamis

Jamis B. wrote:

Yup, good catch, Brad. That’s my fault. When I “fixed” the
switchtower_invoke task to be more configurable, I accidentally
deleted that line. I’ll fix that and package another release asap.

In the meantime, doing as Brad suggested below will correct the
problem for anyone else running into this.

  • Jamis

Jamis, FWIW, once I deployed with 1.0 everything seemed to go fine, but
when I loaded up my app in a browser it became evident that it wasn’t
following the symlinks. I just downgraded to 0.10 and did a deploy,
disable & enable web, and everything works perfectly. (I can see how ST
is going to be quite useful :slight_smile: )

I don’t know enough about ST to be able to tell if this is something
with my setup, or something awry in 1.0, or a little of both. Thought I
would let you know tho…

BTW, I am using the Dreamhost recipe from here:
http://nubyonrails.com/pages/shovel_dreamhost