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

bump ruby, use old ruby for v1 Bundler #9460

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion Dockerfile.updater-core
Expand Up @@ -54,7 +54,9 @@ COPY --chown=dependabot:dependabot LICENSE $DEPENDABOT_HOME

# Install Ruby from official Docker image
# When bumping Ruby minor, need to also add the previous version to `bundler/helpers/v{1,2}/monkey_patches/definition_ruby_version_patch.rb`
COPY --from=docker.io/library/ruby:3.1.4-bookworm --chown=dependabot:dependabot /usr/local /usr/local
COPY --from=docker.io/library/ruby:3.2.3-bookworm --chown=dependabot:dependabot /usr/local /usr/local
# To keep Bundler v1 working, we need to keep the old Ruby binaries
COPY --from=docker.io/library/ruby:3.1.4-bookworm --chown=dependabot:dependabot /usr/local /usr/local/deprecated-ruby

# We had to explicitly bump this as the bundled version `0.2.2` in ubuntu 22.04 has a bug.
# Once Ubuntu base image pulls in a new enough yaml version, we may not need to
Expand Down
4 changes: 4 additions & 0 deletions bundler/helpers/v1/build
Expand Up @@ -2,6 +2,9 @@

set -e

export PATH="/usr/local/deprecated-ruby/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/deprecated-ruby/lib"

helpers_dir=$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)

if [ -z "$DEPENDABOT_NATIVE_HELPERS_PATH" ]; then
Expand All @@ -20,6 +23,7 @@ fi
cd "$install_dir"

export GEM_HOME=$install_dir/.bundle
export GEM_PATH=$install_dir/.bundle

gem install bundler -v 1.17.3 --no-document

Expand Down
8 changes: 8 additions & 0 deletions bundler/helpers/v1/run.rb
@@ -1,6 +1,14 @@
# typed: strict
# frozen_string_literal: true

# output the ruby version to stderr
$stderr.puts "Running Ruby version #{RUBY_VERSION}"
$stderr.puts "PATH is #{ENV['PATH']}"
# Print gem home
$stderr.puts "GEM_HOME is #{ENV['GEM_HOME']}"
# Print gem path
$stderr.puts "GEM_PATH is #{ENV['GEM_PATH']}"

gem "bundler", "~> 1.17"
require "bundler"
require "json"
Expand Down
7 changes: 6 additions & 1 deletion bundler/lib/dependabot/bundler/native_helpers.rb
Expand Up @@ -61,6 +61,8 @@ def self.run_bundler_subprocess(function:, args:, bundler_version:, options: {})
command = BundleCommand
.new(options[:timeout_per_operation_seconds])
.build(File.join(helpers_path, "run.rb"))
path = "/usr/local/deprecated-ruby/bin:#{ENV.fetch('PATH')}" if bundler_version == "1"
ld_library_path = "/usr/local/deprecated-ruby/lib" if bundler_version == "1"
SharedHelpers.run_helper_subprocess(
command: command,
function: function,
Expand All @@ -69,7 +71,10 @@ def self.run_bundler_subprocess(function:, args:, bundler_version:, options: {})
# Set BUNDLE_PATH to a thread-safe location
"BUNDLE_PATH" => File.join(Dependabot::Utils::BUMP_TMP_DIR_PATH, ".bundle"),
# Set GEM_HOME to where the proper version of Bundler is installed
"GEM_HOME" => File.join(helpers_path, ".bundle")
"GEM_HOME" => File.join(helpers_path, ".bundle"),
# Prepend /usr/local/deprecated-ruby to PATH when using V1 Bundler
"PATH" => path,
"LD_LIBRARY_PATH" => ld_library_path
}
)
rescue SharedHelpers::HelperSubprocessFailed => e
Expand Down