How to remove gem from Ruby on Rails application?

后端 未结 6 1660
长情又很酷
长情又很酷 2020-12-08 04:29

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

相关标签:
6条回答
  • 2020-12-08 04:50

    You can use

    gem uninstall <gem-name>

    0 讨论(0)
  • 2020-12-08 04:50

    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.

    0 讨论(0)
  • 2020-12-08 04:52

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

    0 讨论(0)
  • Devise uses some generators to generate views and stuff it needs into your application. If you have run this generator, you can easily undo it with

    rails destroy <name_of_generator>
    

    The uninstallation of the gem works as described in the other posts.

    0 讨论(0)
  • 2020-12-08 05:00

    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)

    0 讨论(0)
  • 2020-12-08 05:11

    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.

    0 讨论(0)
提交回复
热议问题