Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Racksh: A Rails-Console-A-Like for Rack-Based Ruby Apps

By Ric Roberts / November 23, 2009

Have you ever yearned for something like Rails's script/console or Merb's merb -i in your other Rack based apps? If so, then Marcin Kulik's racksh, inspired by Heroku's console, might be for you.

Racksh is a console for Rack based ruby web applications. It allows you run a console in the context of an application environment for Rails, Merb, Sinatra, Camping, Ramaze (or even your own framework) provided there is a rackup file in the root directory.

When you run the racksh command, it loads the whole application environment just like a Rack web server, but instead of running the app it starts an irb session where you can invoke commands.

$ racksh
Rack::Shell v0.9.4 started in development environment.
> Article.all
=> # returns all articles...

As of version 0.9.4 (released this week), racksh uses Bryan Helmkamp's rack-test to simulate HTTP requests to your Rack application via the $rack variable.

$ racksh
Rack::Shell v0.9.4 started in development environment.
> $rack.get "/"
=> # returns a Rack::MockResponse

Racksh also allows you to apply configuration through a .rackshrc file. This can be used to set headers which will be used for requests, or to make additional setup requests (e.g. to make sure a user is logged in).

Install as a gem from Gemcutter, or get the source from Github.

gem install racksh -s

For more details, check out the project's README, and these recent posts on Marcin's blog.


  1. Botanicus says:

    Racksh is great, I have support for it in my Rango framework When you generate a project via rango create project myblog, cd myblog; gem bundle and run ./init.rb -i, you'll get racksh console if racksh is available.

    PS: Unfortunately at the moment you have to use otherwise init.rb will fail, but I sent a pull request, so I hope Marcin will fix it soon.

  2. Marcin Kulik says:

    Hi there, I've already applied Botanicus' patch and relased gem to gemcutter :)

    It's nice to see that new ruby frameworks are using racksh as a default. First was Pancake, now Rango :)

  3. Ric Roberts says:

    Hi Marcin - thanks for your quick turnaround regarding the problems I initially had with racksh.

Other Posts to Enjoy

Twitter Mentions