Skip to content

Commit

Permalink
fix: incompatible gems cache caused corruption (#12)
Browse files Browse the repository at this point in the history
When we use actions/cache to cache the gems (i.e. vendor/bundle
folder), it would introduce this error /usr/bin/env: ‘ruby2.7’: No
such file or directory, because this cache could be cached in a
different OS (e.g. Ubuntu).
  • Loading branch information
jeffreytse committed Mar 22, 2021
1 parent 67aa94f commit a69e57a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ echo "Initial comptible bundler"
${SCRIPT_DIR}/script/cleanup_bundler.sh
gem install bundler -v "${BUNDLER_VER}"

# If the vendor/bundle folder is cached in a differnt OS (e.g. Ubuntu),
# it would cause `jekyll build` failed, we should clean up the uncompatible
# cache firstly.
OS_NAME_FILE=${WORKING_DIR}/vendor/bundle/os-name
os_name=$(cat /etc/os-release | grep ^NAME=)
os_name=${os_name:6:-1}

if [ "$os_name" != "$(cat $OS_NAME_FILE 2>/dev/null)" ]; then
echo "Cleaning up incompatible bundler cache"
rm -rf ${WORKING_DIR}/vendor/bundle/*
echo $os_name > $OS_NAME_FILE
fi

echo "Starting bundle install"
bundle config path ${WORKING_DIR}/vendor/bundle
bundle install
Expand Down

0 comments on commit a69e57a

Please sign in to comment.