Forum: Ruby on Rails Switchtower - unitialized constant

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3fdda7e032a5619199486d05b506ced4?d=identicon&s=25 Brad Daily (bdaily)
on 2006-02-20 00:39
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?
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-02-20 01:19
(Received via mailing list)
On Feb 19, 2006, at 4:39 PM, Brad Daily 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
3fdda7e032a5619199486d05b506ced4?d=identicon&s=25 Brad Daily (bdaily)
on 2006-02-20 01:22
Jamis Buck 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:in `switchtower_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:in
`execute'
/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:in
`execute'
/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:in
`synchronize'
/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:in `run'
/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:in `run'
/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
3fdda7e032a5619199486d05b506ced4?d=identicon&s=25 Brad Daily (bdaily)
on 2006-02-20 01:24
> braddaily$ rake show_deploy_tasks --trace

That trace is actually from

rake remote_exec ACTION=setup --trace

misguided copy and paste :)
3fdda7e032a5619199486d05b506ced4?d=identicon&s=25 Brad Daily (bdaily)
on 2006-02-20 02:24
Brad Daily wrote:
>> braddaily$ rake show_deploy_tasks --trace
>
> That trace is actually from
>
> rake remote_exec ACTION=setup --trace
>
> misguided copy and paste :)

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....
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-02-20 02:59
(Received via mailing list)
On Feb 19, 2006, at 6:24 PM, Brad Daily 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
3fdda7e032a5619199486d05b506ced4?d=identicon&s=25 Brad Daily (bdaily)
on 2006-02-20 03:12
Jamis Buck 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
78b15ebcefd5841518b097a2615ea9ca?d=identicon&s=25 Felix McCoey (Guest)
on 2006-02-20 03:20
(Received via mailing list)
> 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
3fdda7e032a5619199486d05b506ced4?d=identicon&s=25 Brad Daily (bdaily)
on 2006-02-20 03:26
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 : {}
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-02-20 04:05
(Received via mailing list)
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
3fdda7e032a5619199486d05b506ced4?d=identicon&s=25 Brad Daily (bdaily)
on 2006-02-20 04:17
Jamis Buck 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 :) )

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
This topic is locked and can not be replied to.