jorgebucaran / fisher

A plugin manager for Fish
https://git.io/fisher
MIT License
7.65k stars 259 forks source link

Unable to install fisher without a proper TTY #791

Closed inkhey closed 1 week ago

inkhey commented 3 weeks ago

Hello all, thanks for this nice software. I'm using pyinfra tool and wanted to provision fish with fisher and few plugins directly.

I go very straightforward, using the "server.script" function of pyinfra to run a simple fish script that does the fisher installation, using the one-line method…

…and it goes not very well. The process just hangs infinitely there, without any useful information. After digging a bit, i discovered that the script doesn't seem to handle correctly a non-tty interface. I can reproduce the issue with a simple ssh -T:

`❯ ssh -T mymachine "fish -c \"set -l fish_trace on;curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher\""
> curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish
> source
--> function fisher --argument-names cmd --description 'A plugin manager for Fish'
--> if
--> set --query _fisher_upgraded_to_4_4
--> end if
> fisher install jorgebucaran/fisher
--> set --query fisher_path
--> set --local fisher_path /home/vagrant/.config/fish
--> set --local fisher_version 4.4.4
--> set --local fish_plugins /home/vagrant/.config/fish/fish_plugins
--> switch install
----> source /usr/share/fish/functions/isatty.fish
------> function isatty -d 'Tests if a file descriptor is a tty'
---> isatty
-----> set -l options h/help
-----> argparse -n isatty h/help --
-----> if
-----> set -q _flag_help
-----> end if
-----> if
-----> set -q 'argv[2]'
-----> end if
-----> set -l fd
-----> switch ''
------> set fd 0
-----> end switch
-----> test -t 0
---> read --local --null --array stdin
… hang here for the eternity

Is there any simple solution to this issue ? Thanks.

jorgebucaran commented 3 weeks ago

Probably related to:

https://github.com/jorgebucaran/fisher/blob/2efd33ccd0777ece3f58895a093f32932bd377b6/functions/fisher.fish#L23

I really like that ability, but maybe we should remove it for 4.x unless there's a way to have our cake and eat it too.

Could you provide a simple script I can run to repro the issue? The code in your post is kind of unintelligible.

inkhey commented 3 weeks ago

Probably related to:

https://github.com/jorgebucaran/fisher/blob/2efd33ccd0777ece3f58895a093f32932bd377b6/functions/fisher.fish#L23

I really like that ability, but maybe we should remove it for 4.x unless there's a way to have our cake and eat it too.

Could you provide a simple script I can run to repro the issue? The code in your post is kind of unintelligible.

Currently, I don't see any simple way to execute in nontty/non-pty environment other than using ssh -T (maybe using tool like cron ?) :

If you have a local ssh server enabled, you can do this:

ssh -T localhost "fish ./install_fish.fish"

with install fish.fish file locally placed in you home dir:

#!/bin/fish
set -l fish_trace on;
isatty &&  echo "on a tty, don't continue" && exit 43
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fishe

I don't get the tty/pty stuff, but it's seems to be more related to unnexisting pseudo-terminal environment.

The ssh documentation say:

      -T      Disable pseudo-terminal allocation.
jorgebucaran commented 1 week ago

After looking into this further, it seems like this might be a dupe of #742. I'll close here and leave a comment there instead.