Skip to content
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

🐛 Fix sourcing of completion path for Git Bash #801

Merged
merged 5 commits into from
Aug 24, 2024

Conversation

svlandeg
Copy link
Member

@svlandeg svlandeg commented Apr 19, 2024

My system

When running

typer --install-completion

on my Windows system with Git Bash, Typer fetches Path.home() which is C:\Users\Sofie. This is correct in itself, but Git Bash can't work directly with paths that contain backslashes. After installation, .bashrc contains

source C:\Users\Sofie\.bash_completions\typer.sh

and after rebooting the terminal, it will complain:

bash: C:UsersSofie.bash_completionstyper.sh: No such file or directory

To get this to work with Git Bash, .bashrc should instead contain

source 'C:\Users\Sofie\.bash_completions\typer.sh'

and then it works - no error upon starting the console, and the completion feature works.

TODO

This PR needs to be carefully checked on a "normal" Bash system to double check that the single quote doesn't harm any other environments. I wouldn't think so, but I'm not 100% sure.

@svlandeg svlandeg added bug Something isn't working autocompletion os / windows Related to Windows repo / install Installation issues or improvements p2 labels Apr 19, 2024
@svlandeg svlandeg added shell / bash and removed autocompletion repo / install Installation issues or improvements labels Jul 1, 2024
@tiangolo
Copy link
Member

Awesome, thank you @svlandeg! 🙇

I just tested it here on bash under Docker and it's all working.

This will be available in Typer 0.12.5 released in the next few hours. 🎉

@tiangolo tiangolo enabled auto-merge (squash) August 24, 2024 20:58
@tiangolo tiangolo merged commit afac2b8 into fastapi:master Aug 24, 2024
23 checks passed
@svlandeg svlandeg deleted the fix/bash_completion branch August 26, 2024 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working os / windows Related to Windows p2 shell / bash
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants