0

When I write
git push heroku master

my app is successfully pushed to heroku, but it takes about 30sec to a minute because it says it is "Installing gem rails 2.83" and that "Rails is not declared in either .gems or Gemfile."

How do I fix this? What exactly is the .gems file and where does it live?

Thanks a lot. I am completely new to developing in rails and with heroku.

1 Answer 1

6

Heroku has a document that describes the “WARNING: Detected Rails is not declared in either .gems or Gemfile” message and the location, purpose, and syntax of the .gems file. Its URL is given right after the warning message itself:

-----> Heroku receiving push
-----> Rails app detected
-----> WARNING: Detected Rails is not declared in either .gems or Gemfile
       Scheduling the install of Rails 2.3.8.
       See http://docs.heroku.com/gems for details on specifying gems.

First, you should heed the advice to declare your gem dependencies. Since you are using Rails 2.3 it is probably easier to just use a .gems file instead of a Gemfile (though, if like the idea of Bundler, you can still use a Gemfile with Rails 2.3):

# .../project-root/.gems

rails -v 2.3.8
# List any other required gems (and their versions) here

(add and commit the file so Heroku will see it next time you push there)

Second, the “install gems after every push” is at the core of how Heroku operates. They take the tree at the tip of your pushed history and compile it into a read-only “slug” that can be rapidly deployed to and of the servers in their internal network. This trades some “push time” for “deploy time”.

This “build from scratch on every push” behavior would be quite annoying for learning/exploration/development where only small, incremental application changes are usually made between pushes, but there seems to be a way to avoid it for these cases. Just use a .gems file. When an application's declared gem dependencies do not change from one push to another (i.e. no change to the .gems file) they seem to skip the “install of all your gem dependencies from scratch” step.

Bottom Line: Include a .gems file in your project. The next push will still go through “Installing gem rails”, but subsequent pushes should skip that step (unless you change your .gems file to change your set of gem dependencies).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.