Bug #22647
closedarvados-api-server postinst can fail because of gem conflicts
Description
In this part of source:build/rails-package-scripts/postinst.sh :
# As of April 2024/Bundler 2.4, `bundle install` tends not to install gems
# which are already installed system-wide, which causes bundle activation to
# fail later. Work around this by installing all gems manually.
find vendor/cache -maxdepth 1 -name '*.gem' -print0 \
| run_and_report "Installing bundle gems" xargs -0r \
gem install --conservative --ignore-dependencies \
--local --no-document --quiet \
--install-dir="$bundle_path/ruby/$ruby_minor_ver.0"
run_and_report "Running bundle install" "$BUNDLE" install --prefer-local --quiet
run_and_report "Verifying bundle is complete" "$BUNDLE" exec true
The initial gem install
can fail if there are conflicts between gems that are already installed (from previous versions of the package) and gems in the current bundle, as seen in deploy-to-tordo: #1681 :
api.tordo.playg: ERROR: Error installing vendor/cache/rackup-2.2.1.gem: api.tordo.playg: "rackup" from rackup conflicts with installed executable from rack
After this, a manual bundle install
fixed the situation. The postinst didn't get to that line because it aborted after gem install
failed.
So, proposed solution: ignore errors from gem install
. If bundle install
can get us the rest of the way there, then that's all we need and we can let the postinst continue from there. If it doesn't work out, the postinst will fail at bundle install
, and that's fine.
We happened to see this after upgrading to Rails 7.1 but there's nothing specific to Rails or Rack or Passenger about this bug. It could arise with any two gems. This is just the first instance we've happened to see.