sdkman / sdkman-cli

The SDKMAN! Command Line Interface
https://sdkman.io
Apache License 2.0
6.14k stars 631 forks source link

Bug: thread 'main' panicked at 'failed printing to stdout #1182

Closed steinsag closed 1 year ago

steinsag commented 1 year ago

After latest update to

on two independent Ubuntu & Kubuntu 22.04 machines, I get following error whenever I open a new zsh terminal:

/proc/self/fd/14:2: bad pattern: ^[[1
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1009:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

When disabling sdkman in .zshrc, the error message disappears. I have the following in my .zshrc file:

export SDKMAN_DIR="/home/steinchen/.sdkman"
[[ -s "/home/steinchen/.sdkman/bin/sdkman-init.sh" ]] && source "/home/steinchen/.sdkman/bin/sdkman-init.sh"
source <(sdk completion bash)

I think the underlying problems is described in: https://github.com/rust-lang/rust/issues/24821

marc0der commented 1 year ago

Hi @steinsag,

I've just tried replicating this and not getting that error. It seems odd that you are getting such a failure when sdkman doesn't invoke any Rust on shell initialisation. A Rust component is only invoked when you issue a command (such as sdk help).

Here is what I did to try and replicate your issue:

$ docker run -it --rm ubuntu:22.04
# apt update && apt install -y curl zip unzip zsh
# zsh
# curl -s https://get.sdkman.io | bash
# cat /root/.zshrc  

#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"

open a new terminal:

$ docker exec -it da1fc92 zsh
# sdk help
<sick>

Everything works fine, and it also works perfectly on my Arch Linux machine too. What happens if you remove the following obsolete line from your .zshrc?

source <(sdk completion bash)
marc0der commented 1 year ago

@steinsag Okay, I managed to replicate it when I added that line. If you remove it, the problem goes away.

steinsag commented 1 year ago

Forgot to mention that I also have auto environment feature activated, which checks on each directory change.

steinsag commented 1 year ago

@steinsag Okay, I managed to replicate it when I added that line. If you remove it, the problem goes away.

I can confirm that issue is resolved by removing this line. Auto environment feature seems to work as expected, too.

marc0der commented 1 year ago

Great, and you will find auto completion works out of the box with ZSH too. Feel free to close the issue if you feel it answers your question.