Skip to content

macOS without Xcode: fish_prompt spams install prompt dialogs #9343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
floam opened this issue Nov 12, 2022 · 2 comments · Fixed by #9434
Closed

macOS without Xcode: fish_prompt spams install prompt dialogs #9343

floam opened this issue Nov 12, 2022 · 2 comments · Fixed by #9434
Labels
bug Something that's not working as intended macos macOS-specific issue
Milestone

Comments

@floam
Copy link
Member

floam commented Nov 12, 2022

On macOS, /usr/bin/git exists even if git might not be installed - it is a tiny libxcselect.dylib wrapper that basically runs xcrun git which finds git in the installed Xcode or Command Line Tools (...Developer/) path. It prompts the user to install Xcode if they don't have it, which they very well might not if they installed fish via the .pkg installer or are trying the .app bundle. I am not sure what it does if the user isn't an administrator that can't install Xcode anyhow, like if someone tries fish in a computer lab or something.

So, git exists but running git prints an error in this situation:

> git
xcode-select: note: no developer tools were found at '/Applications/Xcode.app',
requesting install. Choose an option in the dialog to download the command line
developer tools.

… and pops up a modal dialog:
Screenshot 2022-11-11 at 3 30 22 PM

Since we try git in fish_git_prompt which fish_prompt tries by default, as long as command -sq git works, this makes fish pretty unusable unless the person relents. The only positive thing I can say, is it is throttled to display no more than once per 10 seconds. It's not our fault, but it's annoying enough I'm calling it a bug.

xcrungit.mp4

The solution here is going to be gating git behind some check if the developer tools are installed if command git is /usr/bin/git on Darwin.

edit: or find a trick to suppress the dialog.

@floam floam added bug Something that's not working as intended macos macOS-specific issue labels Nov 12, 2022
@floam
Copy link
Member Author

floam commented Nov 12, 2022

There is a related issue, that I can't find right now. Possibly, I only ever spoke to @zanchey about it personally. After either Xcode updates, macOS updates, or maybe macOS reboots, the cache xcrun uses is regenerated, which makes fish really slow to launch, because git can take 10+ seconds to do anything while it regenerates/does stuff. So you are sitting there looking at a blank screen waiting for the prompt to print when you open a terminal. Maybe there will be some kind of fix for that too.

edit: just reboots. Because TMPDIR is cleared and the cache is stored at $TMPDIR/xcrun_db.

@floam
Copy link
Member Author

floam commented Nov 12, 2022

The issue was #6625, and it was apparently closed by mistake.

floam added a commit to floam/fish-shell that referenced this issue Nov 12, 2022
Move logic from previous two commits into fish_git_function itself,
and add a check for xcode-select --print-path failing. This indicates
it cannot find a developer dir for xcode or the command line tools.

Return 1 just as if `command -sq git` failed.

Fixes fish-shell#9343
@ridiculousfish ridiculousfish added this to the fish 3.6.0 milestone Dec 26, 2022
ridiculousfish added a commit to ridiculousfish/fish-shell that referenced this issue Dec 26, 2022
git on macOS has two hazards:

1. It comes "preinstalled" as a stub which pops a dialog to install
   command line developer tools.

2. It may populate the xcrun cache when run for the first time, which
   may take several seconds.

We fix these as follows, both fixes limited to Darwin:

1. If git is `/usr/bin/git` and `xcode-select --print-path` fails,
   then do not run git automatically.

2. Second, if there is no file at `xcrun --show-cache-path`, we take it
   as an indication that the cache is not yet populated. In this case we
   run `git` in the background to populate the cache.

Fixes fish-shell#9343
ridiculousfish added a commit to ridiculousfish/fish-shell that referenced this issue Dec 26, 2022
ridiculousfish added a commit to ridiculousfish/fish-shell that referenced this issue Dec 27, 2022
git on macOS has two hazards:

1. It comes "preinstalled" as a stub which pops a dialog to install
   command line developer tools.

2. It may populate the xcrun cache when run for the first time, which
   may take several seconds.

We fix these as follows, both fixes limited to Darwin:

1. If git is `/usr/bin/git` and `xcode-select --print-path` fails,
   then do not run git automatically.

2. Second, if there is no file at `xcrun --show-cache-path`, we take it
   as an indication that the cache is not yet populated. In this case we
   run `git` in the background to populate the cache.

Credit to @floam for the idea.

Fixes fish-shell#9343. Fixes fish-shell#6625.
ridiculousfish added a commit to ridiculousfish/fish-shell that referenced this issue Dec 27, 2022
ridiculousfish added a commit to ridiculousfish/fish-shell that referenced this issue Dec 27, 2022
git on macOS has two hazards:

1. It comes "preinstalled" as a stub which pops a dialog to install
   command line developer tools.

2. It may populate the xcrun cache when run for the first time, which
   may take several seconds.

We fix these as follows, both fixes limited to Darwin:

1. If git is `/usr/bin/git` and `xcode-select --print-path` fails,
   then do not run git automatically.

2. Second, if there is no file at `xcrun --show-cache-path`, we take it
   as an indication that the cache is not yet populated. In this case we
   run `git` in the background to populate the cache.

Credit to @floam for the idea.

Fixes fish-shell#9343. Fixes fish-shell#6625.
ridiculousfish added a commit to ridiculousfish/fish-shell that referenced this issue Dec 27, 2022
ridiculousfish added a commit that referenced this issue Dec 27, 2022
git on macOS has two hazards:

1. It comes "preinstalled" as a stub which pops a dialog to install
   command line developer tools.

2. It may populate the xcrun cache when run for the first time, which
   may take several seconds.

We fix these as follows, both fixes limited to Darwin:

1. If git is `/usr/bin/git` and `xcode-select --print-path` fails,
   then do not run git automatically.

2. Second, if there is no file at `xcrun --show-cache-path`, we take it
   as an indication that the cache is not yet populated. In this case we
   run `git` in the background to populate the cache.

Credit to @floam for the idea.

Fixes #9343. Fixes #6625.
ridiculousfish added a commit that referenced this issue Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that's not working as intended macos macOS-specific issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants