From e3b8b3683f0ac0ce91f9e2684dc593e5f4bea7ab Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Wed, 14 Jul 2021 11:19:58 -0400 Subject: [PATCH] Fix "wrong bundler" error starting API server in arvbox no issue # Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- tools/arvbox/bin/arvbox | 2 +- tools/arvbox/lib/arvbox/docker/api-setup.sh | 6 ++--- tools/arvbox/lib/arvbox/docker/common.sh | 24 ++++++------------- .../lib/arvbox/docker/service/api/run-service | 6 ++--- .../lib/arvbox/docker/service/workbench/run | 2 +- .../docker/service/workbench/run-service | 10 ++++---- 6 files changed, 20 insertions(+), 30 deletions(-) diff --git a/tools/arvbox/bin/arvbox b/tools/arvbox/bin/arvbox index 96f3666cda..9bf6fe1b26 100755 --- a/tools/arvbox/bin/arvbox +++ b/tools/arvbox/bin/arvbox @@ -566,7 +566,7 @@ case "$subcmd" in else echo "Usage: $0 $subcmd " echo "Available services:" - exec docker execa $ARVBOX_CONTAINER ls /etc/service + exec docker exec $ARVBOX_CONTAINER ls /etc/service fi ;; diff --git a/tools/arvbox/lib/arvbox/docker/api-setup.sh b/tools/arvbox/lib/arvbox/docker/api-setup.sh index 4ad2aed0cc..b1b6d37c03 100755 --- a/tools/arvbox/lib/arvbox/docker/api-setup.sh +++ b/tools/arvbox/lib/arvbox/docker/api-setup.sh @@ -56,16 +56,16 @@ EOF fi if ! test -f $ARVADOS_CONTAINER_PATH/api_database_setup ; then - flock $GEM_HOME/gems.lock bundle exec rake db:setup + flock $GEM_HOME/gems.lock bin/bundle exec rake db:setup touch $ARVADOS_CONTAINER_PATH/api_database_setup fi if ! test -s $ARVADOS_CONTAINER_PATH/superuser_token ; then - superuser_tok=$(flock $GEM_HOME/gems.lock bundle exec ./script/create_superuser_token.rb) + superuser_tok=$(flock $GEM_HOME/gems.lock bin/bundle exec ./script/create_superuser_token.rb) echo "$superuser_tok" > $ARVADOS_CONTAINER_PATH/superuser_token fi rm -rf tmp mkdir -p tmp/cache -flock $GEM_HOME/gems.lock bundle exec rake db:migrate +flock $GEM_HOME/gems.lock bin/bundle exec rake db:migrate diff --git a/tools/arvbox/lib/arvbox/docker/common.sh b/tools/arvbox/lib/arvbox/docker/common.sh index eb53e19049..d8f3680491 100644 --- a/tools/arvbox/lib/arvbox/docker/common.sh +++ b/tools/arvbox/lib/arvbox/docker/common.sh @@ -61,27 +61,17 @@ fi run_bundler() { if test -f Gemfile.lock ; then - # The 'gem install bundler line below' is cf. - # https://bundler.io/blog/2019/05/14/solutions-for-cant-find-gem-bundler-with-executable-bundle.html, - # until we get bundler 2.7.10/3.0.0 or higher - flock $GEM_HOME/gems.lock gem install bundler --no-document -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1|tr -d ' ')" frozen=--frozen else frozen="" fi - # if ! test -x $GEM_HOME/bin/bundler ; then - # bundleversion=2.0.2 - # bundlergem=$(ls -r $GEM_HOME/cache/bundler-${bundleversion}.gem 2>/dev/null | head -n1 || true) - # if test -n "$bundlergem" ; then - # flock $GEM_HOME/gems.lock gem install --verbose --local --no-document $bundlergem - # else - # flock $GEM_HOME/gems.lock gem install --verbose --no-document bundler --version ${bundleversion} - # fi - # fi - # Make sure to put the gem binaries in the right place - flock /var/lib/arvados/lib/ruby/gems/2.5.0/gems.lock bundler config bin $GEM_HOME/bin - if ! flock $GEM_HOME/gems.lock bundler install --verbose --local --no-deployment $frozen "$@" ; then - flock $GEM_HOME/gems.lock bundler install --verbose --no-deployment $frozen "$@" + BUNDLER=bundler + if test -x $PWD/bin/bundler ; then + # If present, use the one associated with rails workbench or API + BUNDLER=$PWD/bin/bundler + fi + if ! flock $GEM_HOME/gems.lock $BUNDLER install --verbose --local --no-deployment $frozen "$@" ; then + flock $GEM_HOME/gems.lock $BUNDLER install --verbose --no-deployment $frozen "$@" fi } diff --git a/tools/arvbox/lib/arvbox/docker/service/api/run-service b/tools/arvbox/lib/arvbox/docker/service/api/run-service index d2691e7ed6..c949bffa7c 100755 --- a/tools/arvbox/lib/arvbox/docker/service/api/run-service +++ b/tools/arvbox/lib/arvbox/docker/service/api/run-service @@ -17,8 +17,8 @@ else fi run_bundler --without=development -flock $GEM_HOME/gems.lock bundle exec passenger-config build-native-support -flock $GEM_HOME/gems.lock bundle exec passenger-config install-standalone-runtime +flock $GEM_HOME/gems.lock bin/bundle exec passenger-config build-native-support +flock $GEM_HOME/gems.lock bin/bundle exec passenger-config install-standalone-runtime if test "$1" = "--only-deps" ; then exit @@ -33,4 +33,4 @@ fi touch $ARVADOS_CONTAINER_PATH/api.ready -exec bundle exec passenger start --port=${services[api]} +exec bin/bundle exec passenger start --port=${services[api]} diff --git a/tools/arvbox/lib/arvbox/docker/service/workbench/run b/tools/arvbox/lib/arvbox/docker/service/workbench/run index b8a28fa762..9b588fc4f1 100755 --- a/tools/arvbox/lib/arvbox/docker/service/workbench/run +++ b/tools/arvbox/lib/arvbox/docker/service/workbench/run @@ -23,7 +23,7 @@ fi if test "$1" != "--only-deps" ; then openssl verify -CAfile $root_cert $server_cert - exec bundle exec passenger start --port=${services[workbench]} \ + exec bin/bundle exec passenger start --port=${services[workbench]} \ --ssl --ssl-certificate=$ARVADOS_CONTAINER_PATH/server-cert-${localip}.pem \ --ssl-certificate-key=$ARVADOS_CONTAINER_PATH/server-cert-${localip}.key \ --user arvbox diff --git a/tools/arvbox/lib/arvbox/docker/service/workbench/run-service b/tools/arvbox/lib/arvbox/docker/service/workbench/run-service index 32efea51b1..e6f0ad4a47 100755 --- a/tools/arvbox/lib/arvbox/docker/service/workbench/run-service +++ b/tools/arvbox/lib/arvbox/docker/service/workbench/run-service @@ -23,8 +23,8 @@ else fi run_bundler --without=development -flock $GEM_HOME/gems.lock bundle exec passenger-config build-native-support -flock $GEM_HOME/gems.lock bundle exec passenger-config install-standalone-runtime +flock $GEM_HOME/gems.lock bin/bundle exec passenger-config build-native-support +flock $GEM_HOME/gems.lock bin/bundle exec passenger-config install-standalone-runtime mkdir -p /usr/src/arvados/apps/workbench/tmp if test "$1" = "--only-deps" ; then @@ -34,7 +34,7 @@ cat >config/application.yml <