Skip to content

Commit 1bc3bd6

Browse files
committed
Fix Bun availability in non-login non-interactive shells
/etc/profile.d/ is only sourced by login shells — bash -c, container exec, and CI jobs skip it. Add symlinks in /usr/local/bin for bun/bunx to cover all execution contexts. Also make the profile hook content-idempotent so stale content is corrected on upgrade.
1 parent 6c07263 commit 1bc3bd6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

.devcontainer/scripts/setup.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,24 @@ if [ "$SETUP_POSTSTART" = "true" ]; then
163163
fi
164164

165165
# Fix Bun PATH — external feature only adds to ~/.bashrc (misses non-interactive shells)
166-
if [ -d "$HOME/.bun/bin" ] && [ ! -f /etc/profile.d/bun.sh ]; then
167-
sudo tee /etc/profile.d/bun.sh > /dev/null <<'BUNEOF'
166+
if [ -d "$HOME/.bun/bin" ]; then
167+
# Symlink bun binaries into /usr/local/bin for non-login, non-interactive shells (bash -c, exec)
168+
for bin in bun bunx; do
169+
if [ -x "$HOME/.bun/bin/$bin" ] && [ ! -e "/usr/local/bin/$bin" ]; then
170+
sudo ln -sf "$HOME/.bun/bin/$bin" "/usr/local/bin/$bin"
171+
fi
172+
done
173+
# Profile script sets BUN_INSTALL for login/interactive shells (content-idempotent)
174+
if [ ! -f /etc/profile.d/bun.sh ] || ! grep -q 'BUN_INSTALL="\$HOME/.bun"' /etc/profile.d/bun.sh; then
175+
sudo tee /etc/profile.d/bun.sh > /dev/null <<'BUNEOF'
168176
export BUN_INSTALL="$HOME/.bun"
169177
case ":${PATH}:" in
170178
*:"${BUN_INSTALL}/bin":*) ;;
171179
*) export PATH="${BUN_INSTALL}/bin:${PATH}" ;;
172180
esac
173181
BUNEOF
174-
sudo chmod +x /etc/profile.d/bun.sh
182+
sudo chmod 0644 /etc/profile.d/bun.sh
183+
fi
175184
fi
176185

177186
echo ""

0 commit comments

Comments
 (0)