Yehuda Katz is a member of the Ember.js, Ruby on Rails and jQuery Core Teams; his 9-to-5 home is at the startup he founded, Tilde Inc.. There he works on Skylight, the smart profiler for Rails, and does Ember.js consulting. He is best known for his open source work, which also includes Thor and Handlebars. He travels the world doing open source evangelism and web standards work.

Spinning up a new Rails app

So people have been attempting to get a Rails app up and running recently. I also have some apps in development on Rails 3, so I’ve been experiencing some of the same problems many others have.

The other night, I worked with sferik to start porting merb-admin over to Rails. Because this process involved being on edge Rails, we got the process honed to a very simple, small, repeatable process.

The Steps

Step 1: Check out Rails

$ git clone git://

Step 2: Generate a new app

$ ruby rails/railties/bin/rails new_app
$ cd new_app

Step 3: Edit the app’s Gemfile

# Add to the top
directory "/path/to/rails", :glob => "{*/,}*.gemspec"
git "git://"
git "git://"

Step 4: Bundle

$ gem bundle


Everything should now work: script/server, script/console, etc.

If you want to check your copy of Rails into your app, you can copy it into the app and then change your Gemfile to point to the relative location.

For instance, if you copy it into vendor/rails, you can make the first line of the Gemfile directory "vendor/rails", :glob => => "{*/,}*.gemspec". You’ll want to run gem bundle again after changing the Gemfile, of course.

39 Responses to “Spinning up a new Rails app”

for most of us, that will be

git clone git://

instead of

git clone


Already fixed :)

awesome! thanks for the post, can’t wait to play around with it tomorrow.

Great! Been waiting for this official intro for days.

You should change the GitHub URL to the public clone URL.

Thanks for this article.

sorry, my page was cached and I didn’t notice the previous comments

Typo here: directory “vendor/rails”, :glob => => “{*/,}*.gemspec”

Thanks for the article Yehuda! Happy new years!

You may want to add that we need to have the “bundler” gem installed.

The line

directory “/path/to/rails”, :glob => “{*/,}*.gemspec”

isn’t needed when you run the ‘rails’ command with –dev flag (a recent addition which has been very helpful). It will point to the checkout of Rails you ran the rails command from. example:

ruby rails/railties/bin/rails new_app –dev

I created a ruby script that updates the checkout of rails, automatically sets up an app, with switches to additionally populate it with a post/comment scaffolding, remove public/index.html, make the root url posts#index, and turn on script/server once finished.

I’ve found it very helpful for testing Rails 3. You can find it at

Using the script I mentioned in the previous comment, a great way to get started would be to run:

./generate_rails_app.rb testapp –with-data –start-server

Gem bundle fails for me on windows. Apparently it depends on symlink.

C:/Ruby/lib/ruby/gems/1.9.1/gems/bundler-0.7.2/lib/bundler/bundle.rb:173:in `symlink’: sym
link() function is unimplemented on this machine (NotImplementedError)

Okay, you have to “get install bundler” before…I didn’t knew that.

The following patch to bundler lets me get to the Rails 3 goodness on Windows with these same four steps. Happy New Year!

Why not just use bundler?

% [sudo] gem install bundler # If applicable.
% mkdir appname && cd appname && echo ‘git “git://”
git “git://”
git “git://”‘ > Gemfile
% gem bundle
% bin/rails . -s

I’m getting an error when I follow this recipe:

Could not find gem ‘rails (= 3.0.pre, runtime)’ in any of the sources

Here’s a pastie of my terminal: Here’s a pastie of my Gemfile:

I suppose the “git” directive doesn’t unpack the “rails” executable into “bin”, so the first line of the Gemfile would need to be:

gem “rails”, git: “git://”

Awesome! It’s also succesfully working on the latest ruby!

I also get that error (see my previous comment) with the rails repo in “vendor/rails” (git clone git:// vendor/rails).

Gosh, perhaps I should have replaced “path/to/rails” with the actual path. Disregard all my comments, sorry ;)

Great post.

Also, you could just create a new gemset with rvm and build the rails 3 gems on your own:

ujihisa: It does not work on Ruby 1.9.2-preview1 and Mac OS-X 10.6.2:

The latest commits have broken the generated Rails app. Even when generating a new Rails app from edge now gives weird errors in boot.rb. It might have something to do with the removal config.frameworks etc.

I was able to make this work by pasting this in Gemfile:

gem “rails”, “3.0.pre”, :path => “/Users/rizwanreza/code/rails/railties”
%w(activesupport activemodel actionpack actionmailer activerecord activeresource).each do |lib|
gem lib, ’3.0.pre’, :path => “#{rails_source_path}#{lib}”

I took this from third_rails by Fabio Akita and José Valim. Due to my inexperience with bundler, I am unable to justify the reason behind all this.

Will Rails templates still work in Rails 3, and allow me to specify gem dependencies? I.e. will I be able to specify gems in my template, and have them end up in the Gemfile?

I’ve notice rails 3 uses the name passed to rails binary as base name to a module used by the whole application (in you post example above you used ‘Basecamp’). So, my question is: what if I want to change that in a later stage? Only via find + sed or is there a cosmetic rails-ish way to do that?

I’m getting the following error message:

NoMethodError: undefined method `having’ for #

If you get “Gemspec for rails (3.0.pre) is invalid: Missing require path: ‘lib’” try updating bundler to the latest version.

@Jaroslaw: I get the same problem as you. Did you manage to get past it somehow without replacing the ruby interpreter?

For reference, I had to install the latest interpreter (using “rvm install 1.9.2-head”) which had fixed the problem.

I really want to use merb-admin in my rails app. Where is the rails port living?

I have a problem with rack-mount when I try to bundle gems… :(

$ Fetching git repository at: git://
$ Could not find gem ‘rack-mount (~> 0.4.0, runtime)’ (required by ‘actionpack (= 3.0.pre, runtime)’) in any of the sources
$ No compatible versions could be found for required dependencies:

Here is the full output of “gem bundle” command :

Thanks for your answer.

I try to make a new app following this stpes, but in my Gemfile if i put:
directory “/path/to/rails”, :glob => “{*/,}*.gemspec”
git “git://”
git “git://”

I got this error when i try “script/about”:
`gem_original_require’: no such file to load — rails/all (LoadError)

I have rails 2.3.5 as rails gem, i change in my Gemfile to this conf:
git “git://”
git “git://”
## Bundle edge rails:
gem “rails”, :git => “git://”

and run “gem bundle” and now i can run the “script/about”.

Hmm, the double => is still in the code example (“=> =>”) near the bottom.

Also, I’m getting an error whenever I run rake or any of the binaries:

no such file to load — rails/all

This occurs in config/boot.rb line 16. I followed these steps above (actually putting Rails in vendor/rails and updating Gemfile and running gem bundle).

Any ideas? I’m not familiar with Bundler so it may just be a noob mistake.

The command and API have changed. See this post for a high-level summary:

This only worked for me after removing the directory line when using version 0.9.2 of the bundler gem and git commit b392c818692b39b09836071a30e7a65034e752b5

… also I put rails in vendor/plugins/rails. I’m not sure that had anything to do with it at all but wanting to fully document what I did.

This article is way out of date in light of the bundler changes. See: for up to date instructions on how to start up a rails 3 edge app.

Great code, happy to see this working

notice rails 3 uses the name passed to rails binary as base name to a module used by the whole application (in you post example above you used ‘Basecamp’). So, my question is: what if I want to change that in a later stage? Only via find + sed or is there a cosmetic rails-ish way to do

Leave a Reply