Skip to content

Commit

Permalink
lkp-exec/install: update bundler version to support various ruby
Browse files Browse the repository at this point in the history
Issue appears on centos 7 when doing lkp install.

Fetching: bundler-2.3.26.gem (100%)
ERROR:  Error installing bundler:
        bundler requires Ruby version >= 2.3.0.
/root/lkp-tests/lkp-exec/install: line 344: bundle: command not found

Signed-off-by: Yujie Liu <yujie.liu@intel.com>
Signed-off-by: Philip Li <philip.li@intel.com>
  • Loading branch information
Yujie-Liu authored and rli9 committed Jan 12, 2024
1 parent 8770589 commit 33f5365
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions lkp-exec/install
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,17 @@ install_fakeroot()
fi
}

is_ruby_version_ge()
{
local other_version=$1
# ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
local ruby_version=$(ruby --version | grep -oE "[0-9]+\.[0-9]+\.[0-9]+")

local higher_version=$(echo -e "$other_version\n$ruby_version" | sort -V | tail -n1)

[ "$ruby_version" = "$higher_version" ]
}

install_base_support()
{
install_packages "lkp" "$distro"
Expand All @@ -331,16 +342,34 @@ install_base_support()
install_fakeroot
fi

# https://bundler.io/compatibility.html
# Bundler compatibility with Ruby & RubyGems
# The latest Bundler release should always support, at the very least, all rubies that have not yet reached their End of Life date.
# The latest Bundler release should always support all RubyGems versions higher than or equal to the one shipped with the oldest Ruby version supported. RubyGems is not allowed to be downgraded further than that, so upgrading or downgrading RubyGems should not affect Bundler.
# That effectively comes down to the following:
# Bundler 2.4 or higher
# requires a minimum ruby version of 2.6.0, and a minimum RubyGems version of 3.0.1 (version of RubyGems shipped with ruby 2.6.0).
# Bundler 2.0 through 2.3
# requires a minimum ruby version of 2.3.0, and a minimum RubyGems version of 2.5 (version of RubyGems shipped with ruby 2.3.0).
# Bundler 1
# Requires a minimum Ruby version of 1.8.7, and a minimum RubyGems version of 1.3.6 (version of RubyGems shipped with ruby 1.8.7).

local bundler_version
if is_ruby_version_ge "3.2.0"; then
# bundler-1.17.3/lib/bundler/shared_helpers.rb:35: warning: Pathname#untaint is deprecated and will be removed in Ruby 3.2.
bundler_version="2.3.26"
else
# install bundler 1 to support ruby 2.0.0 at minimum
bundler_version="1.17.3"
fi

if [ -n "$CHINA" ]; then
gem install bundler -v 2.3.26 --clear-sources -s https://gems.ruby-china.com/
gem install bundler -v $bundler_version --clear-sources -s https://gems.ruby-china.com/
bundle_install_china
else
(
cd $LKP_SRC || exit
# install 2.3.26 to avoid below error when ruby is < 2.6.0
# ERROR: Error installing bundler:
# bundler requires Ruby version >= 2.6.0.
gem install bundler -v 2.3.26
gem install bundler -v $bundler_version
bundle install
)
fi
Expand Down

0 comments on commit 33f5365

Please sign in to comment.