[ruby-on-rails] How to remove gem from Ruby on Rails application?

I have installed a gem on my Rails application (devise). After I installed the gem, I realized that I don't need it.

I want to remove the gem, its dependencies and the files it created on my application. In other words, I want to restore the system to what it used to be before the gem. How can I do this? (I'm using Ruby on Rails 3.)

This question is related to ruby-on-rails ruby rubygems

The answer is


If you're using Rails 3+, remove the gem from the Gemfile and run bundle install.

If you're using Rails 2, hopefully you've put the declaration in config/environment.rb. If so, removing it from there and running rake gems:install should do the trick.


For Rails 4 - remove the gem name from Gemfile and then run bundle install in your terminal. Also restart the server afterwards.


You are using some sort of revision control, right? Then it should be quite simple to restore to the commit before you added the gem, or revert the one where you added it if you have several revisions after that you wish to keep.


You can use

gem uninstall <gem-name>


How about something like:

gem dependency devise --pipe | cut -d \  -f 1 | xargs gem uninstall -a

(this assumes that you're not using bundler - but I guess you're not since removing from your bundle gemspec would solve the problem)


Examples related to ruby-on-rails

Embed ruby within URL : Middleman Blog Titlecase all entries into a form_for text field Where do I put a single filter that filters methods in two controllers in Rails Empty brackets '[]' appearing when using .where How to integrate Dart into a Rails app Rails 2.3.4 Persisting Model on Validation Failure How to fix "Your Ruby version is 2.3.0, but your Gemfile specified 2.2.5" while server starting Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? Rails: Can't verify CSRF token authenticity when making a POST request Uncaught ReferenceError: React is not defined

Examples related to ruby

Uninitialized Constant MessagesController Embed ruby within URL : Middleman Blog Titlecase all entries into a form_for text field Ruby - ignore "exit" in code Empty brackets '[]' appearing when using .where find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException) How to update Ruby Version 2.0.0 to the latest version in Mac OSX Yosemite? How to fix "Your Ruby version is 2.3.0, but your Gemfile specified 2.2.5" while server starting Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? How to update Ruby with Homebrew?

Examples related to rubygems

You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException) How to fix "Your Ruby version is 2.3.0, but your Gemfile specified 2.2.5" while server starting You don't have write permissions for the /var/lib/gems/2.3.0 directory Can't install gems on OS X "El Capitan" How to avoid "cannot load such file -- utils/popen" from homebrew on OSX How can I set a proxy server for gem? How to install CocoaPods? Error while installing json gem 'mkmf.rb can't find header files for ruby' How to downgrade or install an older version of Cocoapods