如何在生产环境中使用 bundler 安装额外的 gem?
How to install additional gems with bundler in production environment?
我有一个暂存服务器。我有一些问题想在那里调查。但是我忘了在Gemfile
中加上byebug
。我当然可以在本地添加它,运行 bundle
,提交到存储库,部署。但是没有更简单的方法吗?
当我尝试远程更改 Gemfile
和 运行 bundle
我得到:
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
If this is a development machine, remove the /home/gccs/website-backend/releases/20161018143057/Gemfile freeze
by running `bundle install --no-deployment`.
You have added to the Gemfile:
* byebug
Gems 是用 capistrano
安装的,基本上是这样的:
bundle install --path /home/user/app/shared/bundle --without development test --deployment --quiet
编辑 .bundle/config
将 BUNDLE_FROZEN: '1'
更改为 '0'
(或删除它)足以让 Bundler 在部署环境中管理 gem。然后您可以编辑 Gemfile
、运行 bundle
,重新启动您的应用程序,自定义 gem 就可以使用了。
如果您打算在应用程序之外使用它们 运行时间(f.e。如果您在 rails console
中需要 pry
),则不需要重新启动服务器。
您无法安装其他 gem 的原因是捆绑包已冻结。您可以这样查看:
$ grep FROZEN .bundle/config
BUNDLE_FROZEN: '1'
如果您删除该行(如 所建议)或将“1”更改为“0”,您将能够安装任何您喜欢的 gem,就好像它是开发人员机器一样。但通常最好恢复该值,如果不再需要的话。不确定 bundler
是否会在下次部署时自动执行此操作。
我有一个暂存服务器。我有一些问题想在那里调查。但是我忘了在Gemfile
中加上byebug
。我当然可以在本地添加它,运行 bundle
,提交到存储库,部署。但是没有更简单的方法吗?
当我尝试远程更改 Gemfile
和 运行 bundle
我得到:
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
If this is a development machine, remove the /home/gccs/website-backend/releases/20161018143057/Gemfile freeze
by running `bundle install --no-deployment`.
You have added to the Gemfile:
* byebug
Gems 是用 capistrano
安装的,基本上是这样的:
bundle install --path /home/user/app/shared/bundle --without development test --deployment --quiet
编辑 .bundle/config
将 BUNDLE_FROZEN: '1'
更改为 '0'
(或删除它)足以让 Bundler 在部署环境中管理 gem。然后您可以编辑 Gemfile
、运行 bundle
,重新启动您的应用程序,自定义 gem 就可以使用了。
如果您打算在应用程序之外使用它们 运行时间(f.e。如果您在 rails console
中需要 pry
),则不需要重新启动服务器。
您无法安装其他 gem 的原因是捆绑包已冻结。您可以这样查看:
$ grep FROZEN .bundle/config
BUNDLE_FROZEN: '1'
如果您删除该行(如 bundler
是否会在下次部署时自动执行此操作。