Skip to content

fix: make installer shell detection prefer the reported shell#12942

Open
Byron wants to merge 2 commits intomasterfrom
fix-shell-detection
Open

fix: make installer shell detection prefer the reported shell#12942
Byron wants to merge 2 commits intomasterfrom
fix-shell-detection

Conversation

@Byron
Copy link
Collaborator

@Byron Byron commented Mar 19, 2026

Tasks

  • refackiew

Question for the reviewer

Is there a good reason to not use $SHELL? For all I know, it's only set by the login shell and future sub-shells inherit it.


🧢 Changes

  • prefer the shell reported by $SHELL before falling back to config-file heuristics
  • stop a stray fish config from overriding zsh/bash setup during installation
  • create the selected POSIX shell config file when it does not exist yet, and add regression tests for the selection logic

☕️ Reasoning

The installer was picking fish whenever ~/.config/fish/config.fish existed, even for users running the install from a zsh environment via curl ... | sh. Using the reported shell first matches the user's configured terminal shell and fixes the incorrect completion instructions from #12931.

🎫 Affected issues

Closes #12931

✅ Verification

  • cargo test -p but-installer

@vercel
Copy link

vercel bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gitbutler-web Ignored Ignored Preview Mar 20, 2026 5:14am

Request Review

@github-actions github-actions bot added the rust Pull requests that update Rust code label Mar 19, 2026
@Byron Byron force-pushed the fix-shell-detection branch 2 times, most recently from 2c17d4c to 66931a1 Compare March 19, 2026 23:08
@Byron Byron force-pushed the fix-shell-detection branch 2 times, most recently from 0aebbf6 to b7e42d5 Compare March 20, 2026 03:55
…-based detection otherwise.

Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
@Byron Byron force-pushed the fix-shell-detection branch from b7e42d5 to 8e3bac2 Compare March 20, 2026 04:14
@Byron Byron marked this pull request as ready for review March 20, 2026 04:14
Copilot AI review requested due to automatic review settings March 20, 2026 04:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the but-installer shell detection so it prefers the shell reported by $SHELL over config-file heuristics, preventing an existing fish config from incorrectly overriding zsh/bash during installation.

Changes:

  • Add $SHELL-based shell detection and use it as the primary preference when selecting which shell config to update.
  • Create POSIX shell config files when missing before appending PATH/completions.
  • Add regression tests for preference logic and missing-config creation (introducing insta as a dev dependency for inline snapshots).

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/but-installer/src/shell.rs Prefer $SHELL when selecting shell config; create missing POSIX config files; add regression tests.
crates/but-installer/Cargo.toml Add insta as a dev-dependency for new snapshot-based tests.
Cargo.lock Lockfile update to include insta for but-installer dev builds/tests.

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e3bac24e7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Prefer ~/.bash_profile when the reported shell is Bash on macOS so PATH and completion setup survives
terminal restart. If ~/.bashrc exists but ~/.bash_profile does not, create a minimal ~/.bash_profile that
sources ~/.bashrc before appending installer-managed entries.

Also add macOS regression tests covering fresh Bash configs and the existing-.bashrc case.

Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
@Byron Byron requested a review from krlvi March 20, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@gitbutler/desktop rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong terminal detection after installation

3 participants