-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Don't fail with error when bash is not found or too old #2574
Comments
No they don't, they can be generated at build time and installed to the correct locations. That's actually the intended workflow when distributing an application. |
Thank you for your response! With Homebrew, packages are built and installed in the same place. Unless I misunderstand you? Regardless, it seems unintended for bash to behave differently than zsh and fish. |
I didn't realize it was built on the user's machine. I'm fine with modifying the check to be a warning at generation and an error at runtime. Happy to review aPR. |
Thank you! I'll develop and submit a PR for review tomorrow. |
A quick clarification: by "error at runtime", do you mean checking the bash version at the start of the bash script itself, and displaying the error message then? |
The completion script calls click to produce the results, there's a method in the bash completer class that can be modified. |
I moved the version check from the I see two solutions to this problem:
Option 2 is what I currently have implemented, and it works pretty well. It prints warnings when generating Bash autocompletion with an insufficient version at build time, and resolves this issue. It's also worth mentioning that that the click shell completion documentation details the Bash version requirement in the first paragraph. |
Draft implementation in #2576. |
As discussed in #2152 and #2200,
click
does not support bash shell autocompletion for bash versions older than version 4.4. I understand this and the rational behind this decision, and I am not requesting that this should be changed. However, the way thatclick
makes developers aware of this version limitation has caused an issue with the ability for autocompletion generation to be scripted.I have developed a CLI tool using
click
and I have tried to package it for the Homebrew package manager. As a part of the installation script, autocompletion scripts forbash
,zsh
, andfish
must be generated at installation time. Homebrew isolates builds by removing/usr/local/bin
and all userPATH
s that are not essential for the build. This means that a newer version ofbash
(>4.4) will not be present at build time, even if it is present on the system, which causesclick
to fail to generate bash autocompletion, even if a user has a newer version of bash installed on their system:This error is caused by the following function, which will make bash autocompletion simply fail if it detects that an incompatible version is being used:
click/src/click/shell_completion.py
Lines 304 to 325 in f45198a
It makes sense for bash autocompletion generation to always succeed, like it does for both
zsh
andfish
(zsh and fish autocompletion generation will succeed no matter what, even if neither shell is present on the system). While it is important to notify the user if they are using a version of bash that is too old to be supported, it is a bug for this to cause autocompletion generation to fail entirely. I propose for these error messages to be changed into warning messages that are still displayed, but do not prevent the generation from succeeding.I am willing to submit a pull request myself with the proposed changes if these changes are wanted.
Environment:
The text was updated successfully, but these errors were encountered: