File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,13 +27,30 @@ sudo pacman -S --needed --noconfirm \
2727# Ubuntu / Debian
2828export DEBIAN_FRONTEND= noninteractive
2929
30+ # Retry wrapper for apt commands that may fail due to lock contention
31+ # (e.g. when Coder startup scripts run apt concurrently)
32+ retry_apt() {
33+ local attempt= 1
34+ local max_attempts= 30
35+ while [ " $attempt" -le " $max_attempts" ]; do
36+ if " $@" ; then
37+ return 0
38+ fi
39+ echo " apt command failed (attempt $attempt/$max_attempts), retrying in 5s..."
40+ attempt= $ ((attempt + 1))
41+ sleep 5
42+ done
43+ echo " apt command failed after $max_attempts attempts"
44+ return 1
45+ }
46+
3047# Add fish PPA for latest version
3148if ! command -v fish >/dev/null 2>&1; then
32- sudo apt-add-repository -y ppa:fish-shell/release-3
49+ retry_apt sudo apt-add-repository -y ppa:fish-shell/release-3
3350fi
3451
35- sudo apt-get update -qq
36- sudo apt-get install -y -qq \
52+ retry_apt sudo apt-get update -qq
53+ retry_apt sudo apt-get install -y -qq \
3754 bat \
3855 direnv \
3956 fish \
You can’t perform that action at this time.
0 commit comments