oh-my-fish / oh-my-fish

The Fish Shell Framework
MIT License
10.47k stars 810 forks source link

Calling oh-my-fish installation from a script never returns control to that script #189

Closed netimen closed 8 years ago

netimen commented 8 years ago

I have a python script I run when I install Ubuntu (it installs some apps I need etc). And it installs oh-my-fish as well:

system('sudo apt-get --assume-yes install fish')
system('curl -L github.com/oh-my-fish/oh-my-fish/raw/master/bin/install | fish')
... # other installation code

I run this script in terminal right after installing Ubuntu (15.10). But the problem is that oh-my-fish installation starts fish process and never terminates it, so my script can't continue. I get the following output:

Installing Oh My Fish to /home/d/.local/share/omf...
Cloning master from https://github.com/oh-my-fish/oh-my-fish.git...
Existent config.fish found at /home/d/.config/fish
↳ Moving to /home/d/.config/fish/config.1449221085.copy
Adding startup code to fish config file...
Building Oh My Fish configuration...
Installing package gi
✔ package gi successfully installed.
d@d ~> 

In fact omf installation starts another fish process within itself and never teriminates that, so I even don't see the success report. So the code report success "Installation successful!" also wasn't executed.

htop outputs the following tree:

bash
↳  python
   ↳  fish 
      ↳ fish
bpinto commented 8 years ago

In order to have omf available on your terminal after you install it, we initiate a new shell session after installing it.

You may want to install omf with the env var CI set so it won't do that: set -q CI; or exec fish < /dev/tty

netimen commented 8 years ago

:+1:

derekstavis commented 8 years ago

We plan to avoid this by using source in installer script instead of running a new shell. I'm reopening this issue so we can keep track of it. This issue should be closed when the installer stop leaving a fish orphan process.

sagebind commented 8 years ago

I think this is as fixed as it will ever get. We still launch an interactive terminal from within the installer, which will still cause the above Python script to never finish. However, we do not leave extra fish processes lying around. Here's the process structure when I run the same command (using a sh script):

$ docker run -it --rm ohmyfish/fish:2.3.1
root@170cd71130f1 /# sh -c 'curl -L github.com/oh-my-fish/oh-my-fish/raw/master/bin/install | fish'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   140  100   140    0     0    351      0 --:--:-- --:--:-- --:--:--   351
100 15327  100 15327    0     0  17164      0 --:--:-- --:--:-- --:--:-- 17164
Installing Oh My Fish to /root/.local/share/omf...
Cloning master from https://github.com/oh-my-fish/oh-my-fish.git...
Writing bootstrap to /root/.config/fish/conf.d/omf.fish...
Setting up Oh My Fish configuration...
Installing theme default
✔ theme default successfully installed.
Installation successful!
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
⋊> / pstree -p
fish(1)---sh(44)---fish(46)---pstree(240)

This still doesn't solve the problem though. What you really need is to be able to use the new --noninteractive installer flag. This can now be easily done like this:

system('sudo apt-get --assume-yes install fish')
system('curl -L github.com/oh-my-fish/oh-my-fish/raw/master/bin/install > install')
system('./install --noninteractive')
... # other installation code

This way will tell the installer to not start up an interactive shell (and also to avoid asking any interactive questions).

manojbisht891 commented 6 years ago

I am enabling fish through bash script, so my code is

    substep_info "Installing oh-my-fish"
    curl -L https://get.oh-my.fish | fish

    substep_info "Installing oh-my-fish plugins and themes"
    omf install
    omf install brew cd fonts powerline
    omf install artisan blt
    omf install bobthefish
    omf theme bobthefish
    omf reload

After fish is installed, fish terminal opens up, with default theme, as mentioned above. I have tried to add noninteractive in fish, but it is not initiating noninteractive mode. I also notice one thing, that we have to close the terminal and restart again, to run OMF command, Any help will be appreciated.

AIndoria commented 2 years ago

7 year old issue, is this still the reason the "interactive" mode never gets triggered when installing and everything just installs via default in fish 3.3.1? ./install or fish install is the same.

aindoria@alexandria ~/D/GitHubs> ./install

Checking for a sane environment...

Installing Oh My Fish to /home/aindoria/.local/share/omf...

Using release channel "stable".

Cloning master from https://github.com/oh-my-fish/oh-my-fish.git...

Writing bootstrap to /home/aindoria/.config/fish/conf.d/omf.fish...

Setting up Oh My Fish configuration...

Updating https://github.com/oh-my-fish/packages-main master... Done!

Installing package default

✔ default successfully installed.

Installation successful!

What's the point of

--noninteractive Disable interactive questions (assume no, use with --yes to assume yes).

if it never prompts you anyhow?