fix(install): skip shell config for uninstalled shells#5
Conversation
… errors Guard shell config modifications (PATH additions and hook sourcing) behind existence checks so the installer no longer errors on machines missing zsh, bash, or fish. Daemon and hooks directory creation failures now warn instead of aborting, allowing partial installation to succeed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the robustness and user experience of the installation script by making it more resilient to environments where not all target shells (Zsh, Bash, Fish) are installed or configured. It achieves this by introducing conditional logic for applying shell-specific configurations and by softening error handling for non-critical directory creations, ensuring a smoother installation process across diverse system setups. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request significantly improves the robustness of the installation script. It correctly adds checks to ensure shell configuration files exist before attempting to modify them, preventing errors on systems where certain shells are not installed. The change to use command_exists fish is a smart way to handle the fish shell without creating unnecessary configuration files. Downgrading directory creation failures to warnings for non-essential directories also makes the installation process more resilient. My feedback includes a suggestion to improve consistency in one of the new checks.
| if [ -f "$HOME/.config/fish/config.fish" ]; then | ||
| add_source_to_config "$HOME/.config/fish/config.fish" "${hooks_path}/fish.fish" | ||
| fi |
There was a problem hiding this comment.
For consistency with the fish PATH setup logic (lines 149-160) and the PR description ("Guard fish blocks behind command_exists fish"), it would be clearer to use command_exists fish here as well. While the current file existence check works because the PATH setup section earlier in the script creates config.fish if fish is installed, using the same type of check improves readability and makes the intent more explicit.
| if [ -f "$HOME/.config/fish/config.fish" ]; then | |
| add_source_to_config "$HOME/.config/fish/config.fish" "${hooks_path}/fish.fish" | |
| fi | |
| if command_exists fish; then | |
| add_source_to_config "$HOME/.config/fish/config.fish" "${hooks_path}/fish.fish" | |
| fi |
Code ReviewOverall this is a good fix for a real bug — the original script would error out (or silently corrupt output) when shell config files didn't exist. The approach is sound. A few issues worth addressing before merging: Bug:
|
| if [ $? -ne 0 ]; then | ||
| echo "Error: Failed to create $hooks_path directory." | ||
| exit 1 | ||
| echo "Warning: Failed to create $hooks_path directory. Shell hooks may be unavailable." |
There was a problem hiding this comment.
🔴 Removing exit on hooks_path creation failure allows broken source lines to be added to shell configs
When mkdir -p "$hooks_path" fails at line 198, the old code called exit 1, preventing any further damage. The new code prints a warning and continues. The script then proceeds to: (1) attempt mkdir -p again at install.bash:238 (which also fails), (2) call process_file at install.bash:245-252 where curl -o fails because the directory doesn't exist so no hook files are written, and (3) call add_source_to_config at install.bash:255-263 which adds source ~/.shelltime/hooks/zsh.zsh (and similar) lines to the user's shell config files — pointing to files that don't exist. This causes error messages on every new shell session (e.g., no such file or directory from zsh/bash source). In shells configured with set -e or setopt err_exit, this could abort shell initialization entirely.
Prompt for agents
In install.bash, after the warning at line 199 about failing to create the hooks_path directory, the script should either (a) exit 1 as before, or (b) set a flag (e.g., hooks_failed=true) and check that flag before the add_source_to_config calls at lines 255-263, skipping those calls if hooks directory creation failed. The simplest fix is to restore the exit 1 at line 199, but if the intent is to be graceful, then guard lines 238-263 with a check like: if [ -d "$hooks_path" ]; then ... fi, or add early returns/skips when the directory doesn't exist. The key invariant to maintain: never add source lines to shell configs unless the corresponding hook files actually exist.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
[ -f ~/.zshrc ]/[ -f ~/.bashrc ]checks so missing shells are silently skippedcommand_exists fishinstead of checking config file existence, avoiding creation of fish config dirs on non-fish systems~/.shelltime/daemonand~/.shelltime/hooksmkdir failures from fatal errors to warnings, allowing partial installation to succeedTest plan
bash ./install.bashon a machine without fish installed — should complete without errorsbash ./install.bashon a machine without zsh — should complete without errorsbash ./install.bashon a machine with all shells — all configs should be updated as before~/.shelltime/binmkdir failure still aborts (essential directory)🤖 Generated with Claude Code