开发者

How can I fix an accidental 'sudo bundle install dir_name'?

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?开发者_如何学Python And, my Rails app is complaining when it starts. Is there a way I can revert back?


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.


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!


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜