Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow support for BUNDLE_WITHOUT with spaces #1083

Merged
merged 1 commit into from
Oct 7, 2020

Conversation

schneems
Copy link
Contributor

@schneems schneems commented Oct 7, 2020

In v218 we switched from configuring bundler via flags to env vars. It turns out that bundler supports defining an --without value with a space in it, but it does not support BUNDLE_WITHOUT with a space in it:

$ bundle install --without foo bar
$ bundle config | grep without -a1

without
Set for your local app (/private/tmp/40a4b42d7e884ebf62a1f85a3c5abd38/.bundle/config): [:foo, :bar]

But:

$ BUNDLE_WITHOUT="foo bar" bundle config | grep without -a1

without
Set via BUNDLE_WITHOUT: [:"foo bar"]

Note in this example it is showing :"foo bar" as one group instead of two values.

To fix this, we can reproduce the bundler logic of replacing a space with a colon https://github.com/rubygems/rubygems/blob/ce27b98272d5c37ebf45b2b1b66894699ae47d58/bundler/lib/bundler/cli/install.rb#L151.

Related ticket: https://heroku.support/924687

@schneems schneems requested a review from a team as a code owner October 7, 2020 17:33
@schneems schneems force-pushed the schneems/bundled_with-with-spaces branch from 968841a to 17e646e Compare October 7, 2020 17:34
Copy link
Member

@edmorley edmorley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Would it be worth also wrapping all of the env vars in quotes, to avoid malformed vars breaking the bash command, here?
#1052 (comment)

@schneems schneems force-pushed the schneems/bundled_with-with-spaces branch 2 times, most recently from 9b099f3 to 1e2441f Compare October 7, 2020 17:44
In v218 we switched from configuring bundler via flags to env vars. It turns out that bundler supports defining an `--without` value with a space in it, but it does not support BUNDLE_WITHOUT with a space in it:

```
$ bundle install --without foo bar
$ bundle config | grep without -a1

without
Set for your local app (/private/tmp/40a4b42d7e884ebf62a1f85a3c5abd38/.bundle/config): [:foo, :bar]
```

But:

```
$ BUNDLE_WITHOUT="foo bar" bundle config | grep without -a1

without
Set via BUNDLE_WITHOUT: [:"foo bar"]
```

> Note in this example it is showing `:"foo bar"` as one group instead of two values.

To fix this, we can reproduce the bundler logic of replacing a space with a colon https://github.com/rubygems/rubygems/blob/ce27b98272d5c37ebf45b2b1b66894699ae47d58/bundler/lib/bundler/cli/install.rb#L151. 

Related ticket: https://heroku.support/924687
@schneems schneems force-pushed the schneems/bundled_with-with-spaces branch from 1e2441f to 0ade9e0 Compare October 7, 2020 17:44
@schneems
Copy link
Contributor Author

schneems commented Oct 7, 2020

@edmorley seems good. It's this now:

       remote:        Running: BUNDLE_WITHOUT='foo:bar:baz' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 BUNDLE_GLOBAL_PATH_APPENDS_RUBY_SCOPE=1 bundle install -j4

@schneems schneems merged commit 140fe67 into main Oct 7, 2020
@schneems schneems deleted the schneems/bundled_with-with-spaces branch October 7, 2020 17:52
@edmorley
Copy link
Member

edmorley commented Oct 7, 2020

@schneems Yeah I realise the bug is fixed; I mean more that normally when writing a bash script, it's best practice to put all variable usage inside double quotes (eg it's a shellcheck lint error to not do so). Whilst the bash command for the bundle install is an inline concatenation in Ruby, this still seems like something worth doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants