Skip to content

Instantly share code, notes, and snippets.

@jessereynolds
Created May 21, 2020 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessereynolds/5f071581b28143b06842ceb7a96efce0 to your computer and use it in GitHub Desktop.
Save jessereynolds/5f071581b28143b06842ceb7a96efce0 to your computer and use it in GitHub Desktop.
bundler cannot find a temporary directory

I am encountering the following issue with bundler 1.17.3 and 2.1.4 when executing in a ruby:2.5.8 docker container on Ubuntu 18 with kernel 4.15.0-101-generic. The same project does not exhibit the error on an equivalent container built and run on CentOS 7 with kernel 3.10.0-1127.el7.x86_64.

ArgumentError: could not find a temporary directory
  /usr/local/lib/ruby/2.5.0/tmpdir.rb:35:in `tmpdir'
  /usr/local/lib/ruby/2.5.0/tmpdir.rb:112:in `tmpdir'
  /usr/local/lib/ruby/2.5.0/tmpdir.rb:120:in `create'
  /usr/local/lib/ruby/2.5.0/tmpdir.rb:87:in `mktmpdir'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/compact_index_client/updater.rb:31:in `update'

This is running in a gitlab-ci runner. The full output is as follows:

Running with gitlab-runner 13.0.0 (c127439c)
  on runner1 5zRAsbsu
Preparing the "docker" executor
00:04
Using Docker executor with image puppet_module_testing:latest ...
Using locally found image version due to if-not-present pull policy
Using docker image sha256:ba2213c13351744f31e6c7a071d7b76f9b43560e5d4b139c91c36be920ca8a0f for puppet_module_testing:latest ...
Preparing environment
00:02
Running on runner-5zrasbsu-project-33-concurrent-0 via ubuntu-1804-vanilla...
Getting source from Git repository
00:02
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /tmp/cba/odpeng-odpengsudo/.git/
From https://ps-sdp-gitlab-prod-1.it.puppet.net/cba/odpeng-odpengsudo
 * [new ref]         refs/pipelines/90 -> refs/pipelines/90
   2f568f5..df14092  bionic_bundler    -> origin/bionic_bundler
Checking out df140925 as bionic_bundler...
Skipping Git submodules setup
Restoring cache
00:02
Downloading artifacts
00:02
Running before_script and script
00:02
$ ruby -v
ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux]
$ bundle -v
Bundler version 2.1.4
$ gem --version
3.0.3
$ rm Gemfile.lock || true
rm: cannot remove 'Gemfile.lock': No such file or directory
$ rm -rf ~/.bundle/ ~/.gem/bundler/ ~/.gems/cache/bundler/
$ rm -rf $GEM_HOME/bundler/ $GEM_HOME/cache/bundler/
$ rm -rf .bundle/
$ rm -rf vendor/cache/
$ rm -rf Gemfile.lock
$ gem uninstall rubygems-bundler open_gem
Gem 'rubygems-bundler' is not installed
Gem 'open_gem' is not installed
$ bundle env

Environment

Bundler       2.1.4
  Platforms   ruby, x86_64-linux
Ruby          2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux]
  Full Path   /usr/local/bin/ruby
  Config Dir  /usr/local/etc
RubyGems      3.0.3
  Gem Home    /usr/local/bundle
  Gem Path    /root/.gem/ruby/2.5.0:/usr/local/lib/ruby/gems/2.5.0:/usr/local/bundle
  User Home   /root
  User Path   /root/.gem/ruby/2.5.0
  Bin Dir     /usr/local/bundle/bin
Tools         
  Git         2.20.1
  RVM         not installed
  rbenv       not installed
  chruby      not installed

Bundler Build Metadata

Built At          2020-01-05
Git SHA           32a4159325
Released Version  true

Bundler settings

path
  Set for your local app (/usr/local/bundle/config): "/bundle"
app_config
  Set via BUNDLE_APP_CONFIG: "/usr/local/bundle"
silence_root_warning
  Set via BUNDLE_SILENCE_ROOT_WARNING: true

Gemfile

Gemfile

source ENV['GEM_SOURCE'] || 'https://rubygems.org'
def location_for(place_or_version, fake_version = nil)
  git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
  file_url_regex = %r{\Afile:\/\/(?<path>.*)}
  if place_or_version && (git_url = place_or_version.match(git_url_regex))
    [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
  elsif place_or_version && (file_url = place_or_version.match(file_url_regex))
    ['>= 0', { path: File.expand_path(file_url[:path]), require: false }]
  else
    [place_or_version, { require: false }]
  end
end
ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
minor_version = ruby_version_segments[0..1].join('.')
group :development do
  gem "fast_gettext", '1.1.0',                                   require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
  gem "fast_gettext",                                            require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
  gem "json_pure", '<= 2.0.1',                                   require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
  gem "json", '= 1.8.1',                                         require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
  gem "json", '= 2.0.4',                                         require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
  gem "json", '= 2.1.0',                                         require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
  gem "rb-readline", '= 0.5.5',                                  require: false, platforms: [:mswin, :mingw, :x64_mingw]
  gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby]
  gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4',     require: false, platforms: [:ruby]
  gem "puppet-module-win-default-r#{minor_version}", '~> 0.4',   require: false, platforms: [:mswin, :mingw, :x64_mingw]
  gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4',       require: false, platforms: [:mswin, :mingw, :x64_mingw]
end
puppet_version = ENV['PUPPET_GEM_VERSION']
facter_version = ENV['FACTER_GEM_VERSION']
hiera_version = ENV['HIERA_GEM_VERSION']
gems = {}
gems['puppet'] = location_for(puppet_version)
# If facter or hiera versions have been specified via the environment
# variables
gems['facter'] = location_for(facter_version) if facter_version
gems['hiera'] = location_for(hiera_version) if hiera_version
if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)}
  # If we're using a Puppet gem on Windows which handles its own win32-xxx gem
  # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445).
  gems['win32-dir'] =      ['<= 0.4.9', require: false]
  gems['win32-eventlog'] = ['<= 0.6.5', require: false]
  gems['win32-process'] =  ['<= 0.7.5', require: false]
  gems['win32-security'] = ['<= 0.2.5', require: false]
  gems['win32-service'] =  ['0.8.8', require: false]
end
gems.each do |gem_name, gem_params|
  gem gem_name, *gem_params
end
# Evaluate Gemfile.local and ~/.gemfile if they exist
extra_gemfiles = [
  "#{__FILE__}.local",
  File.join(Dir.home, '.gemfile'),
]
extra_gemfiles.each do |gemfile|
  if File.file?(gemfile) && File.readable?(gemfile)
    eval(File.read(gemfile), binding)
  end
end
# vim: syntax=ruby

Gemfile.lock

<No /tmp/cba/odpeng-odpengsudo/Gemfile.lock found>
$ bundle install --without system_tests --path /bundle --jobs $(nproc)
[DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set path '/bundle'`, and stop using this flag
[DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set without 'system_tests'`, and stop using this flag
The dependency rb-readline (= 0.5.5) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mswin32, x86-mingw32, x64-mingw32. To add those platforms to the bundle, run `bundle lock --add-platform x86-mswin32 x86-mingw32 x64-mingw32`.
The dependency puppet-module-win-default-r2.5 (~> 0.4) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mswin32, x86-mingw32, x64-mingw32. To add those platforms to the bundle, run `bundle lock --add-platform x86-mswin32 x86-mingw32 x64-mingw32`.
The dependency puppet-module-win-dev-r2.5 (~> 0.4) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mswin32, x86-mingw32, x64-mingw32. To add those platforms to the bundle, run `bundle lock --add-platform x86-mswin32 x86-mingw32 x64-mingw32`.
Unfortunately, an unexpected error occurred, and Bundler cannot continue.
--- ERROR REPORT TEMPLATE -------------------------------------------------------

Error Report

Questions

Please fill out answers to these questions, it'll help us figure out why things are going wrong.

  • What did you do? I ran the command /usr/local/bundle/bin/bundle install --without system_tests --path /bundle --jobs 4
  • What did you expect to happen? I expected Bundler to...
  • What happened instead? Instead, what happened was...
  • Have you tried any solutions posted on similar issues in our issue tracker, stack overflow, or google? I tried...
  • Have you read our issues document, https://github.com/bundler/bundler/blob/master/doc/contributing/ISSUES.md? ...

Backtrace

ArgumentError: could not find a temporary directory
  /usr/local/lib/ruby/2.5.0/tmpdir.rb:35:in `tmpdir'
  /usr/local/lib/ruby/2.5.0/tmpdir.rb:112:in `tmpdir'
  /usr/local/lib/ruby/2.5.0/tmpdir.rb:120:in `create'
  /usr/local/lib/ruby/2.5.0/tmpdir.rb:87:in `mktmpdir'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/compact_index_client/updater.rb:31:in `update'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/compact_index_client.rb:98:in `update'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/compact_index_client.rb:85:in `update_and_parse_checksums!'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/fetcher/compact_index.rb:75:in `available?'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/fetcher/compact_index.rb:16:in `call'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/fetcher/compact_index.rb:16:in `block in compact_index_request'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/fetcher.rb:162:in `use_api'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/source/rubygems.rb:388:in `block in api_fetchers'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/source/rubygems.rb:388:in `select'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/source/rubygems.rb:388:in `api_fetchers'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/source/rubygems.rb:393:in `block in remote_specs'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/index.rb:11:in `build'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/source/rubygems.rb:392:in `remote_specs'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/source/rubygems.rb:88:in `specs'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb:273:in `block (2 levels) in index'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb:271:in `each'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb:271:in `block in index'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/index.rb:11:in `build'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb:268:in `index'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb:258:in `resolve'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb:170:in `specs'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/definition.rb:158:in `resolve_remotely!'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/installer.rb:303:in `resolve_if_needed'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/installer.rb:84:in `block in run'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/process_lock.rb:12:in `block in lock'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/process_lock.rb:9:in `open'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/process_lock.rb:9:in `lock'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/installer.rb:73:in `run'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/installer.rb:25:in `install'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/install.rb:66:in `run'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:256:in `block in install'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/settings.rb:124:in `temporary'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:255:in `install'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
  /usr/local/bundle/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
  /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
  /usr/local/bundle/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
  /usr/local/bundle/bin/bundle:23:in `load'
  /usr/local/bundle/bin/bundle:23:in `<main>'

Environment

Bundler       2.1.4
  Platforms   ruby, x86_64-linux
Ruby          2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux]
  Full Path   /usr/local/bin/ruby
  Config Dir  /usr/local/etc
RubyGems      3.0.3
  Gem Home    /bundle/ruby/2.5.0
  Gem Path    /bundle/ruby/2.5.0
  User Home   /root
  User Path   /root/.gem/ruby/2.5.0
  Bin Dir     /bundle/ruby/2.5.0/bin
OpenSSL       
  Compiled    OpenSSL 1.1.1d  10 Sep 2019
  Loaded      OpenSSL 1.1.1d  10 Sep 2019
  Cert File   /usr/lib/ssl/cert.pem
  Cert Dir    /usr/lib/ssl/certs
Tools         
  Git         2.20.1
  RVM         not installed
  rbenv       not installed
  chruby      not installed

Bundler Build Metadata

Built At          2020-01-05
Git SHA           32a4159325
Released Version  true

Bundler settings

path
  Set for your local app (/usr/local/bundle/config): "/bundle"
jobs
  Set for your local app (/usr/local/bundle/config): 4
without
  Set for your local app (/usr/local/bundle/config): [:system_tests]
app_config
  Set via BUNDLE_APP_CONFIG: "/usr/local/bundle"
silence_root_warning
  Set via BUNDLE_SILENCE_ROOT_WARNING: true

Gemfile

Gemfile

source ENV['GEM_SOURCE'] || 'https://rubygems.org'
def location_for(place_or_version, fake_version = nil)
  git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
  file_url_regex = %r{\Afile:\/\/(?<path>.*)}
  if place_or_version && (git_url = place_or_version.match(git_url_regex))
    [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
  elsif place_or_version && (file_url = place_or_version.match(file_url_regex))
    ['>= 0', { path: File.expand_path(file_url[:path]), require: false }]
  else
    [place_or_version, { require: false }]
  end
end
ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
minor_version = ruby_version_segments[0..1].join('.')
group :development do
  gem "fast_gettext", '1.1.0',                                   require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
  gem "fast_gettext",                                            require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
  gem "json_pure", '<= 2.0.1',                                   require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
  gem "json", '= 1.8.1',                                         require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
  gem "json", '= 2.0.4',                                         require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
  gem "json", '= 2.1.0',                                         require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
  gem "rb-readline", '= 0.5.5',                                  require: false, platforms: [:mswin, :mingw, :x64_mingw]
  gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby]
  gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4',     require: false, platforms: [:ruby]
  gem "puppet-module-win-default-r#{minor_version}", '~> 0.4',   require: false, platforms: [:mswin, :mingw, :x64_mingw]
  gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4',       require: false, platforms: [:mswin, :mingw, :x64_mingw]
end
puppet_version = ENV['PUPPET_GEM_VERSION']
facter_version = ENV['FACTER_GEM_VERSION']
hiera_version = ENV['HIERA_GEM_VERSION']
gems = {}
gems['puppet'] = location_for(puppet_version)
# If facter or hiera versions have been specified via the environment
# variables
gems['facter'] = location_for(facter_version) if facter_version
gems['hiera'] = location_for(hiera_version) if hiera_version
if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)}
  # If we're using a Puppet gem on Windows which handles its own win32-xxx gem
  # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445).
  gems['win32-dir'] =      ['<= 0.4.9', require: false]
  gems['win32-eventlog'] = ['<= 0.6.5', require: false]
  gems['win32-process'] =  ['<= 0.7.5', require: false]
  gems['win32-security'] = ['<= 0.2.5', require: false]
  gems['win32-service'] =  ['0.8.8', require: false]
end
gems.each do |gem_name, gem_params|
  gem gem_name, *gem_params
end
# Evaluate Gemfile.local and ~/.gemfile if they exist
extra_gemfiles = [
  "#{__FILE__}.local",
  File.join(Dir.home, '.gemfile'),
]
extra_gemfiles.each do |gemfile|
  if File.file?(gemfile) && File.readable?(gemfile)
    eval(File.read(gemfile), binding)
  end
end
# vim: syntax=ruby

Gemfile.lock

<No /tmp/cba/odpeng-odpengsudo/Gemfile.lock found>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment