[Feature request] `rails install`

originally posted at: https://github.com/rails/rails/issues/29647

Whenever I want to add a gem to my rails app, I go to specific gem’s github repo and follow the Readme instructions. Usually there are couple of steps to install the gem:

  1. Add the gem to your Gemfile
  • This is almost always the same - possible config options could be: require: false or group :development, :test
  1. Run the gem’s generator
  • Usually rails generate gem_name:install or rake gem_name:install:migrations
  1. Migrate the database

I have an idea that would streamline this process and make it easier to add gem to rails apps:

rails install command

This command would install a ruby gem and run any necessary generators and setup code to make the gem fully installed and added to the app.

There are many times when I know the exact name of the gem but I can’t remember how | to | install | the | gem | correctly. Note that every one of these gems has different installation process, although all of these steps in all of these gems can be automatically executed (with sensible defaults that can be changed through cli arguments). Those gems that require more customization (for example: creating migration to add fields to existing models), could output that info right in the console after the installation (something similar to post-install gem message, but displayed every time after rails install command, not only when installing gem for the first time.

Rails is all about Convention-over-Configuration. What we lack here is Convention.

Gem developers could add a simple config option (e.g. in .gemspec file) or dotfile to their gems that will set the flag that this gem follows (new) rails gem installation configuration. Then we could define the necessary instructions to fully install and setup the gem. It could work similarly to rails new template.

Devise does something like this already for their install generator:



This idea comes from ember install:


This seems like something that would be best developed with the rubygems / bundler projects as a lot of gems support more than just Rails projects. Each project that requires more setup than a line in a gemfile would have to adopt this and support it, or that project / rails itself could be perceived as "broken" when 'rails install' doesn't work. Seems like a lot of effort to save 30 seconds of reading and following setup instructions.