Skip to content

Commit 688461e

Browse files
authored
Install Bundler version from Gemfile.lock + add_ruby_env_info (#32)
1 parent 00ec6bd commit 688461e

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

bin/dump_ruby_env_info

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash -eu
2+
3+
echo "--- :ruby: Ruby environment info dump ${1:-}"
4+
5+
if [[ -f .ruby-version ]]; then
6+
cat .ruby-version
7+
else
8+
echo 'Could not find .ruby-version in current folder'
9+
fi
10+
11+
set -x # debug mode: print the commands we call
12+
13+
which ruby
14+
ruby --version
15+
16+
which gem
17+
gem --version
18+
19+
which bundle
20+
gem list bundler
21+
bundle version
22+
23+
set +x # exit debug mode

bin/install_gems

+7-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ CACHEKEY="$BUILDKITE_PIPELINE_SLUG-$ARCHITECTURE-ruby$RUBY_VERSION-$GEMFILE_HASH
77

88
restore_cache "$CACHEKEY"
99

10-
# Ensure we're using the latest version of Bundler before running bundle install.
11-
#
12-
# See https://github.com/Automattic/bash-cache-buildkite-plugin/issues/16 for more details on why this is recommended.
13-
gem install bundler
10+
# Install the same Bundler version as the one in the Gemfile.lock.
11+
# This should prevent runtime issues where Ruby "gets confused" on which Bundler version to use.
12+
# See https://github.com/Automattic/bash-cache-buildkite-plugin/issues/16 for more details.
13+
GEMFILE_LOCK_BUNDLER_VERSION=$(sed -n -e '/BUNDLED WITH/{n;s/ *//p;}' Gemfile.lock)
14+
# The command will fail if the `--version` parameter is empty; we can omit checking for that ourselves.
15+
gem install bundler --version "$GEMFILE_LOCK_BUNDLER_VERSION"
16+
1417
bundle install
1518

1619
# If this is the first time we've seen this particular cache key, save it for the future

0 commit comments

Comments
 (0)