强制捆绑程序在用户的主目录中安装gem [英] Force bundler to install gems in user’s home directory

查看:58
本文介绍了强制捆绑程序在用户的主目录中安装gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上次,我试图学习如何使用Ruby on Rails进行Web开发,并且我使用了Arch GNU / Linux计算机。 Arch的策略要求将gems安装在用户目录中,而不是通常在系统范围内的位置。但是,它与捆绑程序的默认行为(试图在系统范围内安装gems)相矛盾。因此,每当我运行 rails new foo 时,捆绑程序都会要求我输入root密码。

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.

我想强制捆绑程序在我的主目录中安装Rails所需的gem。我尝试运行 bundle install --path .bundle ,但是它会再次下载并安装所有Rails gem,这显然是我不想要的。

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.

您是否知道该怎么做?

更新:最后我是通过运行 bundle install --path〜/ .gem 已经达到了预期的效果。

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

推荐答案

您可以设置环境变量 $ BUNDLE_PATH $ GEM_HOME 。 Bundler将使用这些并将它们安装在此处。如果指定-path my_path ,Bundler将记住此值以供将来安装。

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.


[…],但它会再次下载并安装所有Rails gems,这显然是我不想做的事情。

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

如果要使用宝石的缓存版本,请使用-local

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

这篇关于强制捆绑程序在用户的主目录中安装gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆