Skip to content

[Detail Bug] CLI Completions: Bash login shells don't load installed completions when both .bashrc and .bash_profile exist #267

@detail-app

Description

@detail-app

Detail Bug Report

https://app.detail.dev/org_5f375fe3-a706-4e9a-a6f7-800f2439b3f6/bugs/bug_c7216e1f-299d-45b5-96eb-ea9bc2ad0cb2

Introduced in #182 by @sachiniyer on Mar 11, 2026

Summary

  • Context: The rc_path function in src/commands/completions.rs:31-42 selects ONE bash configuration file to install completions into.
  • Bug: Completions are installed only to .bashrc, but bash login shells read .bash_profile, not .bashrc. When both files exist, login shells will NOT load the completions.
  • Actual vs. expected: Completions work in non-login shells but fail in login shells. They should work in both.
  • Impact: Any user with both .bashrc and .bash_profile who uses login shells (macOS Terminal, SSH, bash -l) will have broken completions.

Code with Bug

"bash" => {
    let bashrc = home.join(".bashrc");
    let profile = home.join(".bash_profile");
    // Prefer .bashrc if it exists, else .bash_profile, else create .bashrc
    if bashrc.exists() {
        Ok(bashrc)      // <-- BUG 🔴 installs only to .bashrc, so login shells won't load it
    } else if profile.exists() {
        Ok(profile)
    } else {
        Ok(bashrc)
    }
}

Explanation

Bash reads different rc files depending on shell type: interactive non-login shells read ~/.bashrc, while login shells read ~/.bash_profile (or ~/.bash_login/~/.profile). The current logic picks a single file and prefers ~/.bashrc when it exists.

This means that when both ~/.bashrc and ~/.bash_profile exist (common on macOS and many SSH setups), running detail completions writes only to ~/.bashrc; starting a login shell then does not source that file, so the completion definition is missing.

Codebase Inconsistency

Rustup updates all existing bash rc files instead of choosing just one:

fn update_rcs(&self, process: &Process) -> Vec<PathBuf> {
    self.rcfiles(process)
        .into_iter()
        .filter(|rc| rc.is_file())  // All existing files
        .collect()
}

Recommended Fix

Install the completions snippet into all existing bash rcfiles (e.g. ~/.bash_profile, ~/.bash_login, ~/.bashrc); if none exist, create/append to ~/.bashrc. Update handle() to append to each selected file while avoiding duplicate insertion.

History

This bug was introduced in commit fd339df. The commit added the entire detail completions feature, including the rc_path function which selected a single bash rc file to install completions. The original implementation preferred .bashrc when it existed, but didn't account for bash login shells reading .bash_profile instead — the single-file design was flawed from the start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions