How to reinstall a gem using bundler

2020-05-14 04:48发布

I did a bundle show and get the complete path to a gem directory.

Unfortunately, I removed the directory using rm -r gem_path. Then my rails app isn't working anymore. If I try start server or start rails console it outputs the following error:

<class:Application>: uninitialized constant MyAPP::Application::Gem (NameError)

What should I do to have it back?

I tried bundle install or bundle update in hope of forcing the bundle to search the gem and install it back, but didn't work.

I also tried delete the Gemfile.lock and run bundle install. Nothing changed, same error.

The gem in question is Act as taggable on.

8条回答
对你真心纯属浪费
2楼-- · 2020-05-14 05:30

bundle exec gem uninstall <gem_name> - uninstalls gem from the bundle (the <app_root>/vendor/bundle/ruby/2.3.0/gems/ path). This is equivalent to the answer @ioquatix gave, but is the slightly more convenient solution that he was looking for.

gem uninstall <gem_name> - uninstalls gem only from the global gemset in the system

查看更多
Root(大扎)
3楼-- · 2020-05-14 05:41

From project directory in terminal

gem uninstall gem_name 
查看更多
登录 后发表回答