Yehuda Katz is a member of the Ruby on Rails core team, and lead developer of the Merb project. He is a member of the jQuery Core Team, and a core contributor to DataMapper. He contributes to many open source projects, like Rubinius and Johnson, and works on some he created himself, like Thor.
@gmcintire Passenger may be setting GEM_HOME differently -- can you print out ENV["GEM_HOME"] in passenger?
Spinning up a new Rails app
December 31st, 2009
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://github.com/rails/rails.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://github.com/rails/arel.git"
git "git://github.com/rails/rack.git"
Step 4: Bundle
$ gem bundle
Done
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.

Neal, Posted December 31, 2009, 10:09 pm
for most of us, that will be
git clone git://github.com/rails/rails.git
instead of
git clone git@github.com:rails/rails.git
:-)
wycats, Posted December 31, 2009, 10:10 pm
Already fixed :)
Neal, Posted December 31, 2009, 10:11 pm
awesome! thanks for the post, can’t wait to play around with it tomorrow.
Dillone, Posted December 31, 2009, 10:18 pm
Great! Been waiting for this official intro for days.
Jeremy Lecour, Posted December 31, 2009, 11:02 pm
You should change the GitHub URL to the public clone URL.
Thanks for this article.
Jeremy Lecour, Posted December 31, 2009, 11:10 pm
sorry, my page was cached and I didn’t notice the previous comments
Robert Evans, Posted December 31, 2009, 11:14 pm
Typo here: directory “vendor/rails”, :glob => => “{*/,}*.gemspec”
Thanks for the article Yehuda! Happy new years!
Jeremy Lecour, Posted December 31, 2009, 11:17 pm
You may want to add that we need to have the “bundler” gem installed.
Kieran P, Posted January 1, 2010, 12:53 am
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 http://gist.github.com/225330
Kieran P, Posted January 1, 2010, 1:01 am
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
Matt H, Posted January 1, 2010, 1:51 am
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)
murphy, Posted January 1, 2010, 3:10 am
Okay, you have to “get install bundler” before…I didn’t knew that.
Matt H, Posted January 1, 2010, 3:22 am
The following patch to bundler lets me get to the Rails 3 goodness on Windows with these same four steps. Happy New Year!
http://github.com/MattHulse/bundler/commit/5c9c0fb32186b91ebb4038ddbabd6dcae10e5cd5
Stephen Celis, Posted January 1, 2010, 11:39 am
Why not just use bundler?
% [sudo] gem install bundler # If applicable.
% mkdir appname && cd appname && echo ‘git “git://github.com/rails/rails.git”
git “git://github.com/rails/arel.git”
git “git://github.com/rails/rack.git”‘ > Gemfile
% gem bundle
% bin/rails . -s
August Lilleaas, Posted January 1, 2010, 12:57 pm
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: http://pastie.org/763281 Here’s a pastie of my Gemfile: http://pastie.org/763282
Stephen Celis, Posted January 1, 2010, 1:40 pm
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://github.com/rails/rails.git”
ujihisa, Posted January 1, 2010, 7:04 pm
Awesome! It’s also succesfully working on the latest ruby! http://gyazo.com/b89514ce762770e92810e330e37a3f39.png
August Lilleaas, Posted January 1, 2010, 8:59 pm
I also get that error (see my previous comment) with the rails repo in “vendor/rails” (git clone git://github.com/rails/rails.git vendor/rails).
August Lilleaas, Posted January 1, 2010, 9:01 pm
Gosh, perhaps I should have replaced “path/to/rails” with the actual path. Disregard all my comments, sorry ;)
Konstantin Haase, Posted January 2, 2010, 6:44 am
Great post.
Also, you could just create a new gemset with rvm and build the rails 3 gems on your own: http://gist.github.com/267470
Jaroslaw Zabiello, Posted January 2, 2010, 7:49 pm
ujihisa: It does not work on Ruby 1.9.2-preview1 and Mac OS-X 10.6.2: http://pastie.org/764462
Rizwan Reza, Posted January 2, 2010, 8:23 pm
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.
Rizwan Reza, Posted January 3, 2010, 9:56 am
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}”
end
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.
Craig Buchek, Posted January 4, 2010, 3:53 pm
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?
Leandro N. Camargo, Posted January 5, 2010, 7:58 pm
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?
Conrad Taylor, Posted January 8, 2010, 9:18 am
I’m getting the following error message:
NoMethodError: undefined method `having’ for #
Mikel Lindsaar, Posted January 14, 2010, 12:05 am
If you get “Gemspec for rails (3.0.pre) is invalid: Missing require path: ‘lib’” try updating bundler to the latest version.
Greger Olsson, Posted January 14, 2010, 2:36 pm
@Jaroslaw: I get the same problem as you. Did you manage to get past it somehow without replacing the ruby interpreter?
Greger Olsson, Posted January 15, 2010, 6:10 am
For reference, I had to install the latest interpreter (using “rvm install 1.9.2-head”) which had fixed the problem.
Andrew Roth, Posted January 15, 2010, 1:00 pm
I really want to use merb-admin in my rails app. Where is the rails port living?
Batzooh, Posted January 19, 2010, 9:59 am
I have a problem with rack-mount when I try to bundle gems… :(
$ Fetching git repository at: git://github.com/rails/rack-mount.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 : http://pastie.org/784831
Thanks for your answer.
Batzooh.
Agustin Viñao, Posted January 24, 2010, 10:44 am
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://github.com/rails/arel.git”
git “git://github.com/rails/rack.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://github.com/rails/arel.git”
git “git://github.com/rails/rack.git”
## Bundle edge rails:
gem “rails”, :git => “git://github.com/rails/rails.git”
and run “gem bundle” and now i can run the “script/about”.
Matt Todd, Posted January 29, 2010, 10:18 am
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.
Geoffrey Grosenbach, Posted February 1, 2010, 12:20 pm
The command and API have changed. See this post for a high-level summary: http://yehudakatz.com/2010/02/01/bundler-0-9-heading-toward-1-0/
Scott Noel-Hemming, Posted February 6, 2010, 2:17 am
This only worked for me after removing the directory line when using version 0.9.2 of the bundler gem and git commit b392c818692b39b09836071a30e7a65034e752b5
Scott Noel-Hemming, Posted February 6, 2010, 2:18 am
… 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.
Sam, Posted February 6, 2010, 5:08 am
This article is way out of date in light of the bundler changes. See: http://rails3.community-tracker.com/permalinks/r/7/6/what-is-the-simplest-way-to-get-a-rails-3-edge-app-started#6 for up to date instructions on how to start up a rails 3 edge app.
Dana, Posted July 13, 2010, 8:06 pm
Great code, happy to see this working