How can I fix an accidental 'sudo bundle insta

2019-02-08 13:38发布

I accidentally ran sudo bundle install smtp_mail and now all my gems are in this directory called smtp_mail inside my Rails app.

I'm not sure about the default location of gems? And, my Rails app is complaining when it starts. Is there a way I can revert back?

标签: ruby gem bundler
4条回答
劳资没心,怎么记你
2楼-- · 2019-02-08 13:46

This helped me when I ran into a simular issue.

I rm -rf all files in .bundle and then removed and then I followed the commands in this document.

http://ruby-korea.github.io/bundler-site/issues.html.

查看更多
冷血范
3楼-- · 2019-02-08 13:57

pay attention on this...

from the bundle man page:

By default, bundler installs gems to the same location as gem install.

You should never use sudo bundle install. This is because several other steps in bundle install must be performed as the current user:

Updating your Gemfile.lock Updating your vendor/cache, if necessary Checking out private git repositories using your user's SSH keys

Of these three, the first two could theoretically be performed by chowning the resulting files to $SUDO_USER. The third, however, can only be performed by actually invoking the git command as the current user. Therefore, git gems are downloaded and installed into ~/.bundle rather than $GEM_HOME or $BUNDLE_PATH.

As a result, you should run bundle install as the current user, and bundler will ask for your password if it is needed to put the gems into their final location.

查看更多
你好瞎i
4楼-- · 2019-02-08 14:02

The path is specified in a file located in

.bundle/config  

If you delete the .bundle directory and then delete your smtp_mail directory you will be back at square one. If you really want a local (to your app) installation of the gems, I recommend you run

bundle install --path vendor/bundle

Good luck!

查看更多
在下西门庆
5楼-- · 2019-02-08 14:09

After a bit of Googling around i was able to find the answer Just run:

sudo bundle install --system and you'll have your gems back at their appropriate system directories.

查看更多
登录 后发表回答