Somehow I stumbled across this great little tool — oh yeah, John Nunemaker mentioned “powder,” which was “Syntactic sugar for http://pow.cx/”
Huh? Syntactic what? For “pow” what? John hasn’t steered me wrong yet, so I decided I needed to look at what Pow was. In 37Signals own words:
Pow: Zero-configuration Rack Server for Mac OS X
In other words:
You can run a bunch of your rails apps all at once, with ease.
This is worth the effort to try and get running to see if it will help ease how you work with multiple Rails apps.
Since my experience was a bit off from the awesome-looking Screencast teaser, I figured I would share it in case others might benefit from the troubleshooting.
Once I solved the Pow-not-working-like-magic-from-the-start problems, it worked right out of the box with a Rails3 App. Not so much with my Rails2 apps. So, you can either try to do it the Rails3 way from the start (see below for instructions), or barge ahead and see how far you get (knowing now what I do for Rails2, barging is probably a pretty safe bet).
Yes, I am repeating what is in the main website… but then aggregating common troubleshooting experiences ad fixes below, to save you (and my colleagues) time.
$ curl get.pow.cx | sh
Be certain you see “*** Installed” or it is not! (See Troubleshooting section below if need be.)
jonsmac2-2:.pow jon$ curl get.pow.cx | sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2722 100 2722 0 0 17322 0 --:--:-- --:--:-- --:--:-- 34455 *** Installing Pow 0.2.2... *** Installing local configuration files... *** Starting the Pow server... *** Installed
If you get upset, just uninstall:
$ curl get.pow.cx/uninstall.sh | sh
$ cd ~/.pow $ ln -s /path/to/myapp
To the right is an example. Name the link if you do not want to use the default folder name. For example:
ln -s ~/railsprojects/first_app jkfirstapp
This allows you to then enter the following into the browser, using the symbolic link name (or the default folder name):
If that didn’t work, continue onward, your journey will be short (I hope).
I was disappointed when the magic didn’t happen right away. Boy does the Ruby community spoil us! So a hunting I will go…
Create a Rails3 App
If you are only doing Rails2, see below for the config.ru fix. Otherwise, creating a vanilla Rails3 app is a good way to test that Pow is properly configured. Here is a simple Rails3 app (from Michael Hartl’s Ruby on Rails3 Tutorial):
mkdir ~/railsprojects rails new first_app
edit the Gemfile:
gem 'rails', '3.0.1' gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
bundle install rails server
It should be running with the default server page.
I got Nothing!
If pow did not install, or you get seemingly NOTHING when going to the browser webpage, look no further than here. The following worked for me (and others). Seems that the permissions are not quite right sometimes:
-rw-rw-r-- 1 jon staff 518B Apr 18 13:42 cx.pow.powd.plist
So I ran this:
jonsmac2-2:.pow jon$ launchctl load -Fw ~/Library/LaunchAgents/cx.pow.powd.plist jonsmac2-2:.pow jon$ chmod 644 ~/Library/LaunchAgents/cx.pow.powd.plist jonsmac2-2:.pow jon$ curl get.pow.cx | sh
And, after the re-install, the perms ended up as you might expect:
-rw-r--r-- 1 jon staff 518B Apr 18 13:42 cx.pow.powd.plist
Checking It’s Running
This is admittedly odd output for a “working” install, but it gives you at least one data point to compare what you get versus this. Do the following:
cd ~/Library/Application Support/Pow/Current/bin jonsmac2-2:bin jon$ ./pow
On my Mac it results in:
node.js:134 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: EADDRINUSE, Address already in use at HttpServer._doListen (net.js:1089:5) at net.js:1060:14 at Object.lookup (dns.js:159:5) at HttpServer.listen (net.js:1054:20) at Array.<anonymous> (/Users/jon/Library/Application Support/Pow/Versions/0.2.2/lib/daemon.js:34:27) at EventEmitter._tickCallback (node.js:126:26)
Domain Isn’t Setup
If you see this:
Then you know you have screwed up the symbolic link.
Try again, and be careful and exact.
Trouble Accessing Dev domains
Some folks needed this simple fix:
Rails2: Cannot GET /? –> config.ru is Missing!
That’s right, you see:
Cannot GET / in the browser. Bet you never saw that before!
This means that you are missing the Rackup config.ru file in your application’s root. Try adding this file (you can see it in the folder screenshot above):
# This file is used by Rack-based servers to start the application. require "./config/environment" use Rails::Rack::LogTailer use Rails::Rack::Static run ActionController::Dispatcher.new
Pow Can’t Start Your App
This is most likely, genuinely, truly your error… Sorry to say!
The error below is because the config.ru was completely wrong (I was trying the Rails3 project file (duh — it invokes a class in a module named after the app itself)):
Pow can’t start your application.
/Users/jon/railsprojects/track_my_league/tml raised an exception during boot.
NameError: uninitialized constant FirstApp /Users/jon/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant' /Users/jon/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing' /Users/jon/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing' /Users/jon/railsprojects/track_my_league/tml/config.ru:4 /Users/jon/Library/Application Support/Pow/Versions/0.2.2/node_modules/nack/lib/nack/builder.rb:4:in `instance_eval' /Users/jon/Library/Application Support/Pow/Versions/0.2.2/node_modules/nack/lib/nack/builder.rb:4:in `initialize' /Users/jon/railsprojects/track_my_league/tml/config.ru:1:in `new' /Users/jon/railsprojects/track_my_league/tml/config.ru:1
Here the error is that I do not have the gem environment set up properly with RVM (using .rvmrc). Easily diagnosed because I can’t even start the app manually!
SystemExit: exit ./config/boot.rb:66:in `exit' ./config/boot.rb:66:in `load_rails_gem' ./config/boot.rb:54:in `load_initializer' ./config/boot.rb:38:in `run' ./config/boot.rb:11:in `boot!' ./config/boot.rb:110 ./config/environment.rb:7:in `require' ./config/environment.rb:7 /Users/jon/railsprojects/tml/TML/config.ru:3:in `require' /Users/jon/railsprojects/tml/TML/config.ru:3 /Users/jon/Library/Application Support/Pow/Versions/0.2.2/node_modules/nack/lib/nack/builder.rb:4:in `instance_eval' /Users/jon/Library/Application Support/Pow/Versions/0.2.2/node_modules/nack/lib/nack/builder.rb:4:in `initialize' /Users/jon/railsprojects/tml/TML/config.ru:1:in `new' /Users/jon/railsprojects/tml/TML/config.ru:1
Hope this helps!
Great post, there should be more like this when something new comes out…
Is the config.ru code you have at “Rails2: Cannot GET /? –> config.ru is Missing!” kind of the most general version of config.ru and should it work with all Rails 2 apps?
And, yes, the config.ru seems to be generic enough. At least it worked with each of my Rails2 apps…
I’ve also found if you’re running RBM but havent set up a specific version(just using the default) for an an app… you need to add an .rvmrc (hidden) file to your app to make it boot properly..
Im not sure this is documented anywhere… (or if *I* in fact am making the error by not setting a version in rvm….) but I’ve been stuck on this a few times…
typo… Thats rvm (in the first line) my bad…