How to reinstall a gem using bundler

前端 未结 8 1771

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 ap

8条回答
  •  野性不改
    2021-01-30 20:22

    If you've installed into ./bundle/vendor or similar, you need to remove the gem first but explicitly specify the GEM_HOME, e.g.

    GEM_HOME=./vendor/bundle/ruby/2.3.0/ gem uninstall rmagick
    

    This is by far the simplest way to uninstall gems installed using bundler into a vendor directory. Ideally, there would be a command bundle uninstall or bundle reinstall, etc.

    If your goal is to simply reinstall, the following command will help:

    GEM_HOME=./vendor/bundle/ruby/2.3.0/ gem uninstall rmagick && sudo -u http bundle install
    

    If you're like me and have several web-applications under a directory (e.g. /srv/http), the following does it in all directories:

    cd /srv/http
    for d in ./*/ ; do (cd "$d" && sudo -u http GEM_HOME=./vendor/bundle/ruby/2.4.0/ gem uninstall --force rmagick && sudo -u http bundle install); done
    

提交回复
热议问题