Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

bundler inline fails when BUNDLE_BIN is set (default in docker) #5847

Closed
robuye opened this issue Jul 7, 2017 · 2 comments · Fixed by #5848
Closed

bundler inline fails when BUNDLE_BIN is set (default in docker) #5847

robuye opened this issue Jul 7, 2017 · 2 comments · Fixed by #5848

Comments

@robuye
Copy link
Contributor

robuye commented Jul 7, 2017

Hi there,

I'm trying to use bundler/inline feature to dockerize some scripts that require gems to be installed. I was able to reproduce the problem locally, it's doesn't appear to be docker specific issue.

Steps to reproduce:

Create example script in /tmp/inline.rb:

require 'bundler/inline'

gemfile(true) do
  source 'https://rubygems.org'

  gem 'aws-sdk'
end

Run the script in official docker container:

docker run --rm -v /tmp/inline.rb:/inline.rb -it ruby:2.4 ruby /inline.rb

Result:

Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/.
Resolving dependencies...
Fetching aws-sigv4 1.0.0
Installing aws-sigv4 1.0.0
Fetching jmespath 1.3.1
Installing jmespath 1.3.1
Using bundler 1.15.1
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/installer/parallel_installer.rb:142:in `handle_error': ArgumentError: different prefix: "" and "/usr/local/bundle/bin" (Bundler::InstallError)
An error occurred while installing aws-sigv4 (1.0.0), and Bundler cannot continue.
Make sure that `gem install aws-sigv4 -v '1.0.0'` succeeds before bundling.

In Gemfile:
  aws-sdk was resolved to 2.10.9, which depends on
    aws-sdk-resources was resolved to 2.10.9, which depends on
      aws-sdk-core was resolved to 2.10.9, which depends on
        aws-sigv4
        from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/installer/parallel_installer.rb:104:in `call'
        from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/installer/parallel_installer.rb:77:in `call'
        from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/installer.rb:199:in `install_in_parallel'
        from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/installer.rb:166:in `install'
        from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/installer.rb:80:in `run'
        from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/installer.rb:24:in `install'
        from /usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/inline.rb:63:in `gemfile'

It works when BUNDLE_BIN is unset or false:

docker run -e BUNDLE_BIN=false --rm -v /tmp/inline.rb:/inline.rb -it ruby:2.4 ruby /inline.rb

Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/.
Resolving dependencies...
Fetching aws-sigv4 1.0.0
Installing aws-sigv4 1.0.0
Fetching jmespath 1.3.1
Installing jmespath 1.3.1
Using bundler 1.15.1
Fetching aws-sdk-core 2.10.9
Installing aws-sdk-core 2.10.9
Fetching aws-sdk-resources 2.10.9
Installing aws-sdk-resources 2.10.9
Fetching aws-sdk 2.10.9
Installing aws-sdk 2.10.9

Output of bundle env from docker container:

bundle env
## Environment

Bundler   1.15.1
Rubygems  2.6.12
Ruby      2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
GEM_HOME  /usr/local/bundle
GEM_PATH  
Git       2.1.4
Platform  x86_64-linux

## Bundler settings

silence_root_warning
  Set via BUNDLE_SILENCE_ROOT_WARNING: "1"
app_config
  Set via BUNDLE_APP_CONFIG: "/usr/local/bundle"
bin
  Set via BUNDLE_BIN: "/usr/local/bundle/bin"
path
  Set via BUNDLE_PATH: "/usr/local/bundle"

This is from the official, up to date, ruby docker image. I'm getting exactly same error on my local environment by running BUNDLE_BIN=/tmp ruby /tmp/inline.rb.

The workaround I'm using now is to simply update the script with ENV['BUNDLE_BIN'] = nil at the very top. That works, but it feels to be a bug so I'm creating an issue.

Thanks so much for doing awesome work on bundler and taking time to look into this problem!

@segiddins
Copy link
Member

Thanks for the 💯 issue! #5848 should fix this.

@robuye
Copy link
Contributor Author

robuye commented Jul 7, 2017

Thanks so much @segiddins! 💯 👍 😻

bundlerbot added a commit that referenced this issue Jul 8, 2017
[Inline] Work when BUNDLE_BIN is set

### What was the end-user problem that led to this PR?

The problem was that `bundler/inline` would fail when `$BUNDLE_BIN` was set.

Closes #5847.

### What was your diagnosis of the problem?

My diagnosis was we needed to skip installing binstubs when doing an inline install.

### What is your fix for the problem, implemented in this PR?

My fix sets a temporary setting for `:inline` and skips installing binstubs when that's true.

### Why did you choose this fix out of the possible options?

I chose this fix because it was minimally intrusive.
segiddins pushed a commit that referenced this issue Jul 17, 2017
[Inline] Work when BUNDLE_BIN is set

### What was the end-user problem that led to this PR?

The problem was that `bundler/inline` would fail when `$BUNDLE_BIN` was set.

Closes #5847.

### What was your diagnosis of the problem?

My diagnosis was we needed to skip installing binstubs when doing an inline install.

### What is your fix for the problem, implemented in this PR?

My fix sets a temporary setting for `:inline` and skips installing binstubs when that's true.

### Why did you choose this fix out of the possible options?

I chose this fix because it was minimally intrusive.

(cherry picked from commit 1075e44)

# Conflicts:
#	lib/bundler/installer.rb
#	spec/quality_spec.rb
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants