Force bundler to install gems in user’s home directory

江枫思渺然 提交于 2019-12-20 17:36:15

问题


Last time I’m trying to learn how to do web development with Ruby on Rails and I use my Arch GNU/Linux machine for it. The policy of Arch requires gems to be installed in the user directory instead of usual system‐wide location. However, it contradicts the default behavior of the bundler (which tries to install gems system‐wide). So whenever I run rails new foo the bundler asks me to enter my root password.

I want to force bundler to install gems required by Rails in my home directory. I tried running bundle install --path .bundle but it downloads and installs all of the Rails gems one more time which is obviously what I don’t want to do.

Do you have any idea how to do it?

Update: Finally I’ve got a desired effect by running bundle install --path ~/.gem.


回答1:


You can set an environment variables $BUNDLE_PATH or $GEM_HOME. Bundler will use those and install your gems there. If you specify --path my_path, Bundler will remember this value for future installations.

[…] but it downloads and installs all of the Rails gems one more time which is obviously what I don’t want to do.

If you want to use cached versions of your gems use --local.



来源:https://stackoverflow.com/questions/16031061/force-bundler-to-install-gems-in-user-s-home-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!