ruby - 如何通过 Chef 配置 Bundler?
问题描述
我们使用 Chef 来设置和执行 Bundler。我们之前在and属性设置为的资源中运行bundle install
, (捆绑器操作旨在以该用户身份运行)。bash
user
group
target_user
由于某些选项(即--deployment
,--path
和--without
)的弃用,我们现在需要通过配置它们bundle config
。
但是,似乎在使用相同的资源配置时,Bundle 无法按预期工作;我们得到Bundler::SudoNotPermittedError: Bundler requires sudo access to install...
,我想这是因为配置文件没有存储在正确的位置,和/或读取。
资源应该如何execute
配置?目前,它是:
# Simplified version
bash "Install gems" do
code <<~EOF
bundle config --local deployment true &&
bundle config --local path /path/to/gems_dir &&
bundle install --gemfile=/path/to/Gemfile
EOF
user "target_user"
group "target_user"
end
解决方案
您将此bash
资源作为target_user运行,这就是错误的原因。我认为您在这里有两个选择:
- 从资源中删除用户和组,然后它将以 root 身份运行。
- 在中的每个捆绑命令之前添加sudo
code
,并确保target_user是没有密码的 sudoer。
推荐阅读
- rust - 我们如何在 sqlx rust 中定义一个 jsonb 和 UUID 字段?
- python - 启动前的内核访问和停止进程
- c - Realloc() 用于结构
- tomcat8 - 什么是文件 .asscache (tomcat 8)
- hybris - 启用/禁用 b2bunit 的权限
- akeneo - 产品修改历史(akeneo)
- react-native - React Native Web 问题与 react-native-vector-icons
- php - PHP - 使用 json_decode 访问属性
- php - 永久链接字段在基本 Instagram API 中不起作用
- java - 无法使用 KlassMaster 混淆 jar - Kotlin 问题