5

I am spinning a docker container(alpine base) from a docker file inside a Jenkins pipeline. The container installs: ruby-rake and ruby-bundler and I am able to do bundle with no problem

My working directory in this jenkins pipeline has Gemfile and Gemfile.lock I try to run bundle install in this working directory

when I try:

bundle install #running as a shell command in jenkins 

I get:

`/` 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

What do I have to do to install my Ruby gems of Gemfile and Gemfile.lock?

Jake Worth
  • 5,490
  • 1
  • 25
  • 35
David
  • 1,469
  • 5
  • 33
  • 51
  • `Make sure that 'gem install rake -v '10.3.2' succeeds before bundling.` I would start here – chevybow Jun 20 '18 at 20:56
  • @chevybow I am afraid, that's not the issue in this case. The issue is that my jenkins user has no access to where gem is re-building the install context for the dependencies. Directory : /.gem/ruby/2.4.0/cache/rake-10.3.2.gem – David Jun 20 '18 at 22:22
  • And the question becomes, whilst bundle is available inside the container, how do I use that bundle to install the Gemfile dependencies as the jenkins user? – David Jun 20 '18 at 22:23

2 Answers2

1

It looks like you don't have access to root, so bundler is using another directory instead.

What happens next is your user doesn't have access to the right gem directory because it doesn't exist! Try running bundle config path NEW_PATH_HERE to set a proper directory which your user can access.

Alternatively you can specify a new path with: bundle install --path /some/path

Joseph Cho
  • 4,033
  • 4
  • 26
  • 33
1

You can set BUNDLE_PATH (env var) and this will be fixed you can check the configuration on the bundle documentation