Skip to content

Instantly share code, notes, and snippets.

@mokagio
Last active June 11, 2020 05:30
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 mokagio/7dfcd75ffc2fac278c2bde4862c3164b to your computer and use it in GitHub Desktop.
Save mokagio/7dfcd75ffc2fac278c2bde4862c3164b to your computer and use it in GitHub Desktop.
Script to reproduce the behavior described in https://github.com/rubygems/rubygems/issues/3708
#!/bin/bash
# I run this only on macOS
set -ex
ISSUE=3708
ROOT_DIR=/tmp/repro-$ISSUE
rm -rf $ROOT_DIR
mkdir -p $ROOT_DIR
cd $ROOT_DIR
bundle env
# ## Environment
#
# ```
# Bundler 2.1.4
# Platforms ruby, x86_64-darwin-19
# Ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9cec0d0ffcba012279cd652d28ad5bf3) [x86_64-darwin19]
# Full Path /Users/gio/.rbenv/versions/2.7.1/bin/ruby
# Config Dir /Users/gio/.rbenv/versions/2.7.1/etc
# RubyGems 3.1.2
# Gem Home /Users/gio/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
# Gem Path /Users/gio/.gem/ruby/2.7.0:/Users/gio/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
# User Home /Users/gio
# User Path /Users/gio/.gem/ruby/2.7.0
# Bin Dir /Users/gio/.rbenv/versions/2.7.1/bin
# Tools
# Git 2.26.2
# RVM not installed
# rbenv rbenv 1.1.2
# chruby not installed
# ```
#
# ## Bundler Build Metadata
#
# ```
# Built At 2020-06-11
# Git SHA unknown
# Released Version false
# ```
cat > Gemfile <<RUBY
source 'https://rubygems.org'
# Note: these gems are chosen purely because they come with no dependencies.
# The behavior can be reproduced with any gem set.
gem 'dotenv'
group :optional_group, optional: true do
gem 'safe_yaml'
end
RUBY
bundle config set --local path "vendor/bundle"
cat .bundle/config
# ---
# BUNDLE_PATH: "vendor/bundle
bundle install
# Fetching gem metadata from https://rubygems.org/..
# Resolving dependencies...
# Using bundler 2.1.4
# Fetching dotenv 2.7.5
# Installing dotenv 2.7.5
# Bundle complete! 2 Gemfile dependencies, 2 gems now installed.
# Bundled gems are installed into `./vendor/bundle`
#
# ✅ this is what I'd expect only dotenv installed, in the specified path.
BUNDLE_WITH=optional_group bundle install
# Fetching gem metadata from https://rubygems.org/.........
# Using bundler 2.1.4
# Using dotenv 2.7.5
# Fetching safe_yaml 1.0.5
# Installing safe_yaml 1.0.5
# Bundle complete! 2 Gemfile dependencies, 3 gems now installed.
# Bundled gems are installed into `./vendor/bundle`
#
# ✅ this is what I'd expect all gems installed, in the specified path
cat .bundle/config
# ---
# BUNDLE_PATH: "vendor/bundle"
# BUNDLE_WITH: "optional_group"
#
# 🤔 I wasn't expecting .bundle/config to change when calling `bundle install`
# with an environment variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment