postinstall does not add ~/.capsem/bin to PATH for fish
- Dominant language
- Rust
- Stars
- 72
- Forks
- 13
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 5
Description
# postinstall does not add ~/.capsem/bin to PATH for fish
## Summary
The macOS `.pkg` postinstall script adds `~/.capsem/bin` to PATH for zsh and bash, but not fish. fish users install the package, get fish completions, but `capsem` is not on PATH in new fish sessions.
## Location
https://github.com/google/capsem/blob/d166a81ebc6208ec643b8a7b0ac81fcf5c81c0d6/scripts/pkg-scripts/postinstall#L125-L135
The loop only covers `.zshrc`, `.bash_profile`, `.bashrc`. fish is not handled, and it can't be folded into this loop: fish uses `fish_add_path` rather than `export PATH=...`, and its config lives at `~/.config/fish/config.fish`.
## Why it matters
fish is an explicitly supported shell elsewhere in the package — `capsem
completions fish` is documented in help and generated by clap.
## Proposed fix
Add a fish-specific branch after the existing loop. fish syntax and config
location are independent of the POSIX-shell profiles.
```diff
# Add ~/.capsem/bin to PATH in shell profile
CAPSEM_BIN="$CAPSEM_DIR/bin"
for PROFILE in "$USER_HOME/.zshrc" "$USER_HOME/.bash_profile" "$USER_HOME/.bashrc"; do
if [ -f "$PROFILE" ]; then
if ! grep -qF '.capsem/bin' "$PROFILE"; then
echo 'export PATH="$HOME/.capsem/bin:$PATH"' >> "$PROFILE"
chown "$USER" "$PROFILE"
fi
break
fi
done
+
+# fish uses its own syntax (fish_add_path) and config location, independent of
+# the POSIX-shell profiles above.
+FISH_CONFIG="$USER_HOME/.config/fish/config.fish"
+if command -v fish >/dev/null 2>&1 || [ -f "$FISH_CONFIG" ]; then
+ mkdir -p "$(dirname "$FISH_CONFIG")"
+ if ! grep -qF '.capsem/bin' "$FISH_CONFIG" 2>/dev/null; then
+ echo 'fish_add_path "$HOME/.capsem/bin"' >> "$FISH_CONFIG"
+ fi
+ chown -R "$USER" "$USER_HOME/.config/fish"
+fi
```
The `grep` guard keeps it idempotent across reinstalls; the `command -v fish ||
-f config` check avoids creating fish config for users who don't have fish.
Contributor guide
Assessment
This issue has not been assessed yet.