fix(fnm): load managed Node from always-on zsh layer
fnm lived in interactive-only ~/.config/zshrc, so ssh/agents/zsh -c missed fnm-managed node. Source ~/.config/zsh/*.zsh from .zshenv and install the fragment as zsh/fnm instead.
This commit is contained in:
+40
-2
@@ -74,18 +74,20 @@ printf '%s\n' 'existing-zshenv' | cmp -s - "$main_home/.zshenv" ||
|
||||
fnm_home="$TEMP_DIR/fnm-home"
|
||||
mkdir -p "$fnm_home/.local/share/fnm"
|
||||
ln -s /usr/bin/true "$fnm_home/.local/share/fnm/fnm"
|
||||
HOME="$fnm_home" PATH=/usr/bin:/bin zsh -c 'source "$1"; command -v fnm >/dev/null' zsh "$ROOT/zshrc/fnm.zsh" ||
|
||||
HOME="$fnm_home" PATH=/usr/bin:/bin zsh -c 'source "$1"; command -v fnm >/dev/null' zsh "$ROOT/zsh/fnm.zsh" ||
|
||||
fail "fnm is not restored to PATH in a new Zsh session"
|
||||
|
||||
for script in "$ROOT"/*.sh; do
|
||||
bash -n "$script"
|
||||
done
|
||||
|
||||
for config in "$ROOT/.zshenv" "$ROOT/.zshrc" "$ROOT"/zshrc/*.zsh; do
|
||||
for config in "$ROOT/.zshenv" "$ROOT/.zshrc" "$ROOT"/zshrc/*.zsh "$ROOT"/zsh/*.zsh; do
|
||||
[[ -f "$config" ]] || continue
|
||||
zsh -n "$config"
|
||||
done
|
||||
[[ ! -e "$ROOT/.zprofile" ]] || fail "easyzsh should not ship a managed .zprofile"
|
||||
[[ -f "$ROOT/zsh/fnm.zsh" ]] || fail "always-on fnm fragment is missing"
|
||||
[[ ! -e "$ROOT/zshrc/fnm.zsh" ]] || fail "legacy interactive fnm fragment still exists"
|
||||
|
||||
grep -q 'NVM_VERSION="v0.40.4"' "$ROOT/install_nvm.sh" || fail "nvm version is stale"
|
||||
grep -q 'apt-get install -y unzip' "$ROOT/install_fnm.sh" || fail "Ubuntu unzip installation is missing"
|
||||
@@ -101,6 +103,8 @@ grep -Fq 'brew shellenv' "$ROOT/.zshenv" || fail "Homebrew is not initialized in
|
||||
grep -Fq '/usr/local/bin/brew' "$ROOT/.zshenv" || fail "Intel Homebrew path is missing from .zshenv"
|
||||
grep -Fq '$HOME/.local/bin' "$ROOT/.zshenv" || fail "~/.local/bin is not added in .zshenv"
|
||||
grep -Fq 'local.zsh' "$ROOT/.zshenv" || fail "local.zsh is not sourced from .zshenv"
|
||||
grep -Fq 'ZSH_ALWAYS_ON_DIR' "$ROOT/.zshenv" || fail "always-on ~/.config/zsh/*.zsh glob is missing from .zshenv"
|
||||
grep -Fq 'zsh/fnm' "$ROOT/install_fnm.sh" || fail "install_fnm.sh does not patch always-on zsh/fnm"
|
||||
if grep -Fq 'brew shellenv' "$ROOT/.zshrc"; then
|
||||
fail "Homebrew still initializes from interactive-only .zshrc"
|
||||
fi
|
||||
@@ -137,4 +141,38 @@ HOME="$local_bin_home" PATH=/usr/bin:/bin \
|
||||
zsh -c '. ~/.zshenv; command -v easyzsh-path-probe >/dev/null' ||
|
||||
fail "~/.local/bin is not available to non-interactive zsh via .zshenv"
|
||||
|
||||
# Non-interactive zsh must load always-on ~/.config/zsh/*.zsh (fnm) via .zshenv.
|
||||
fnm_env_home="$TEMP_DIR/fnm-env-home"
|
||||
mkdir -p "$fnm_env_home/.local/share/fnm" "$fnm_env_home/.config/zsh"
|
||||
ln -s /usr/bin/true "$fnm_env_home/.local/share/fnm/fnm"
|
||||
cp "$ROOT/zsh/fnm.zsh" "$fnm_env_home/.config/zsh/fnm.zsh"
|
||||
HOME="$fnm_env_home" bash "$ROOT/deploy.sh" --home "$fnm_env_home" >/dev/null
|
||||
HOME="$fnm_env_home" PATH=/usr/bin:/bin \
|
||||
zsh -c 'command -v fnm >/dev/null' ||
|
||||
fail "always-on fnm is not available to non-interactive zsh via .zshenv"
|
||||
|
||||
# patch.sh path form installs into ~/.config/zsh/
|
||||
path_patch_home="$TEMP_DIR/path-patch-home"
|
||||
path_bin="$TEMP_DIR/path-bin"
|
||||
mkdir -p "$path_patch_home" "$path_bin"
|
||||
cat >"$path_bin/curl" <<'CURL'
|
||||
#!/bin/bash
|
||||
out=""
|
||||
url=""
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-o) out="$2"; shift 2 ;;
|
||||
-*) shift ;;
|
||||
*) url="$1"; shift ;;
|
||||
esac
|
||||
done
|
||||
[[ "$url" == */zsh/fnm.zsh ]] || exit 1
|
||||
printf '%s\n' '# patched-fnm' >"$out"
|
||||
CURL
|
||||
chmod +x "$path_bin/curl"
|
||||
# Prefer real coreutils for mktemp/mkdir used by patch.sh
|
||||
HOME="$path_patch_home" PATH="$path_bin:/usr/bin:/bin" bash "$ROOT/patch.sh" zsh/fnm >/dev/null
|
||||
grep -Fxq '# patched-fnm' "$path_patch_home/.config/zsh/fnm.zsh" ||
|
||||
fail "patch.sh zsh/fnm did not install ~/.config/zsh/fnm.zsh"
|
||||
|
||||
echo "installer checks passed"
|
||||
|
||||
Reference in New Issue
Block a user