【问题标题】:Cannot install gems with bundle无法使用 bundle 安装 gem
【发布时间】:2018-11-30 01:41:18
【问题描述】:

我正在从 Jenkins 管道内的 docker 文件中旋转一个 docker 容器(alpine base)。容器安装: ruby-rake and ruby-bundler 而且我可以毫无问题地进行捆绑

我在这个 jenkins 管道中的工作目录有 Gemfile 和 Gemfile.lock 我尝试在这个工作目录中运行 bundle install

当我尝试时:

bundle install #running as a shell command in jenkins 

我明白了:

`/` is not writable.
Bundler will use `/tmp/bundler/home/unknown' as your home directory temporarily.
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/.

Resolving dependencies.............
Fetching rake 10.3.2

Retrying download gem from https://rubygems.org/ due to error (2/4): Errno::ENOENT No such file or directory @ rb_sysopen - /.gem/ruby/2.4.0/cache/rake-10.3.2.gem
Retrying download gem from https://rubygems.org/ due to error (3/4): Errno::ENOENT No such file or directory @ rb_sysopen - /.gem/ruby/2.4.0/cache/rake-10.3.2.gem
Retrying download gem from https://rubygems.org/ due to error (4/4): Errno::ENOENT No such file or directory @ rb_sysopen - /.gem/ruby/2.4.0/cache/rake-10.3.2.gem
Errno::ENOENT: No such file or directory @ rb_sysopen -
/.gem/ruby/2.4.0/cache/rake-10.3.2.gem
An error occurred while installing rake (10.3.2), and Bundler cannot continue.
Make sure that `gem install rake -v '10.3.2'` succeeds before bundling.

In Gemfile:
  aws_account_utils was resolved to 0.1.4, which depends on
  rake

我必须做些什么来安装我的 Gemfile 和 Gemfile.lock 的 Ruby gem?

【问题讨论】:

  • Make sure that 'gem install rake -v '10.3.2' succeeds before bundling. 我会从这里开始
  • @chevybow 恐怕在这种情况下这不是问题。问题是我的 jenkins 用户无权访问 gem 为依赖项重新构建安装上下文的位置。目录:/.gem/ruby/2.4.0/cache/rake-10.3.2.gem
  • 问题就变成了,虽然容器内有 bundle 可用,但我如何以 jenkins 用户的身份使用该 bundle 安装 Gemfile 依赖项?

标签: ruby jenkins-pipeline bundler gemfile gemfile.lock


【解决方案1】:

您可以设置BUNDLE_PATH(环境变量),这将得到修复 你可以在bundle documentation上查看配置

【讨论】:

    【解决方案2】:

    您似乎无权访问 root,因此 bundler 正在使用另一个目录。

    接下来发生的事情是您的用户无权访问正确的 gem 目录,因为它不存在!尝试运行bundle config path NEW_PATH_HERE 来设置您的用户可以访问的正确目录。

    您也可以指定一个新路径:bundle install --path /some/path

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-25
      • 2016-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-21
      • 2020-04-11
      • 1970-01-01
      相关资源
      最近更新 更多