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
Completion script initialisation problems #912
Comments
Hi @johann-petrak, Looking at this, I think you have something else going on with your system. We don't have any references to If the problem persists, please feel free to chat with us on the SDKMAN slack as described in the contributor guidelines. |
As I said, it provably only ever happens whe sdkman is in the .bashrc - i deliberately observed both settings for several weeks. It looks as if in the sdkman bash code some variable gets expanded to unexpected results. |
After chatting on Slack, we discovered an interaction with the |
As it turns out, this probably comes from the second line of code that gets included in the .bashrc by the sdkman installation:
This command is supposed to emit bash code that gets sourced on stdout but sometimes, the command When enabling debug mode in
This is probably NOT what was causing the original intermittent problem (as the symptoms are different) but it is very likely that the sdk function may occasionally also emit other messages or output other than just the bash code when running For me, as a workaround to test, I have changed the lines in .bashrc to:
I do not understand why the installation procedure does not do it like this in the first place, I do not think there |
I have the same problem. Sometimes when I open up the shell, I see " Here is what i found out: Normally, the completion snippets will be generated and inserted here. However sometimes sdkman finds updates and prepends a broadcast message to the output. So the output of
This output is then A propper fix would be to disable broadcast messages in the completion subcommand. Hope I could help :) |
I have the same problem with CentOS 6.x |
We will be releasing a fix for this as soon as possible. In the meanwhile, please reference the file directly from your bash/ZSH profile like @johann-petrak suggested. |
FWIW I'm also affected by this, and the workaround suggested by @johann-petrak appears to be working fine. One slight tweak that might make it more generally reusable is to leverage the source "$SDKMAN_DIR/contrib/completion/bash/sdk" Also, in terms of general recommendation for setting up completion, I wonder isn't it more efficient to simply source the completion file directly rather than invoking a command that'll echo the completion? |
Thanks for the fix! Still curious though: why does the skd installation procedure not just put the code for sourcing the appropriate completion file directly, why does this need to go through the sdk function? |
Agreed, it would be a better option. We could even source it from within the |
I think we have a tactical fix for now, but I'm going to keep this open so we can do this properly. |
Okay, changes have been made and are on master (and available to try in the beta channel). All that is required now is to add It will automatically sense your shell and source the appropriate completion script. Please give it a go and let me know if that works. |
Great! |
I can confirm that the current beta version does not produce any warnings when I fire up my shell. Completion works as expected in zsh. Thank you very much. |
@johann-petrak yes exactly, but I've done it in such a way that having that snippet in there (for people that have already added it) won't break anything. I've also removed @jochenwierum excellent stuff, glad to hear that it's working 👍 |
After pulling in from the beta channel, all good on my end as well. 👍 BTW @marc0der, now that the |
Ah, I thought I'd removed it. Yes indeed. I'm also going to remove the |
Hey, I just tried to type
I'm not sure if this is related to the current bug but, if that update notice gets sourced, then it would cause a bug resembling to this one. Edit: ok, I see this was already pointed by this comment. Sorry for the noise. |
@christophehenry are you seeing this on the beta channel? This is where we've fixed it. |
I've done some final cleanup on this feature and addressed the completion tweaks as suggested by @vpavic. Please give it a final test before I release this version into the wild. |
I've just pulled the latest from the beta channel (i.e. On top of verifying that the completion is set up properly using
$ sdk
broadcast current env help install offline uninstall upgrade version
config default flush home list selfupdate update use
$ sdk help
Usage: sdk <command> [candidate] [version]
sdk offline <enable|disable>
commands:
install or i <candidate> [version] [local-path]
uninstall or rm <candidate> <version>
list or ls [candidate]
use or u <candidate> <version>
config
default or d <candidate> [version]
home or h <candidate> <version>
env or e [init|install|clear]
current or c [candidate]
upgrade or ug [candidate]
version or v
broadcast or b
help
offline [enable|disable]
selfupdate [force]
update
flush [archives|tmp|broadcast|version]
candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc.
use list command for comprehensive list of candidates
eg: $ sdk list
version : where optional, defaults to latest stable if not provided
eg: $ sdk install groovy
local-path : optional path to an existing local installation
eg: $ sdk install groovy 2.4.13-local /opt/groovy-2.4.13
$ sdk completion bash && echo $?
0 |
Great to hear. Also, there will be no unexpected broadcasts or update messages. I'll release it shortly. |
Well, you also removed the Anyway, thank you for your work here. Really helpful! 👍 |
@christophehenry The completion command is still there but is now simply noop with 0 return code. This guarantees backward compatibility. I've simply removed all references to it so it's no longer advertised. |
This has now been resolved and was released in 5.11.5. |
But please advertise that we need to manually modify Maybe in Installation guide, add a section that explains how we can enable completions, or maybe in future release, you can set |
Using sdkman SDKMAN 5.11.2+698 on Ubuntu Linux 20.04 and bash 5.0.17(1) with the necessary code in .bashrc to put it in the path.
When I start a new terminal, i.e. invoke a new bash, output like the following sometimes appears on the console:
I did not manage to find out why/when this happens, it appears to be almost random, though it usually happens when opening the first terminal after a restart or after a longer time.
I have observed this behaviour for several weeks now and I am certain this only happens when the SDKMAN-related code is active in .bashrc, never happens when I comment that out.
The "command not found" complaints I get appear to come from strings inside the bash prompt definition and from the names of random directories in my home directory. I have no idea at all what could be going on here, but it became so annoying that I usually deactivate sdkman completely.
So sadly, I cannot provide steps to reproduce because this problem occurs seemingly randomly (but often enough to be very annoying).
The text was updated successfully, but these errors were encountered: