busybox-w32 icon indicating copy to clipboard operation
busybox-w32 copied to clipboard

need `/bin/sh` for certain scenarios, such running neovim for Windows under busybox.

Open tigerinus opened this issue 3 years ago • 9 comments

Context:

busybox-win32 is my default shell on Windows 10.

Repro:

  1. Run neovim for windows under busybox for windows
  2. Run :checkhealth

Result:

provider: health#provider#check
========================================================================
  - ERROR: Failed to run healthcheck for "provider" plugin. Exception:
    function health#check[20]..health#provider#check[5]..<SNR>116_check_node[20]..script C:\Program Files\Neovim\share\nvim\runtime\autoload\provider\node.vim[160]..function provider#node#Detect, line 16
    Vim(let):E903: Process failed to start: no such file or directory: "/bin/sh"

It'd be nice to have /bin/sh path to get this work.

tigerinus avatar Oct 10 '22 00:10 tigerinus

Error E903 is issued by the function channel_job_start() in src/nvim/channel.c. In this case it's trying to spawn a process with argv[0] set to /bin/sh. On Windows this isn't an absolute path: it refers to the file /bin/sh on the current drive. Such a file won't exist in a default Windows installation.

I'm not sure there's anything busybox-w32 should do about this.

(When busybox-w32 is asked to execute /bin/sh and the file doesn't exist it uses the built in shell applet instead. But in this case it's neovim that's trying to run /bin/sh.)

rmyorston avatar Oct 10 '22 09:10 rmyorston

Can it override the file request to /bin/sh at exec level, just like how it is overridden at shell level?

tigerinus avatar Oct 10 '22 12:10 tigerinus

The special treatment of a non-existent /bin/sh in busybox-w32 applies both in the shell and at exec level. But in this case the problem isn't in busybox-w32, it's in neovim.

A partial workaround is to make C:\bin\sh.exe a link to busybox-w32 (or a copy of it). That only works if your current drive is C:, though.

rmyorston avatar Oct 10 '22 15:10 rmyorston

I see.

It's not a blocking issue. I will use neovim under cmd.exe as a workaround for now. Thanks!

tigerinus avatar Oct 10 '22 16:10 tigerinus

How does running neovim from cmd.exe help?

rmyorston avatar Oct 10 '22 20:10 rmyorston

If running from cmd.exe, neovim no longer assumes itself running under a POSIX environment and thus no longer seek for /bin/sh.

tigerinus avatar Oct 10 '22 20:10 tigerinus

It's probably looking at some env var, so you can probably modify the var when launching neovim, e.g. using an alias.

Another option is to report this issue to neovim, because ultimately it is a neovim issue. I'm sure it should be fairly easy to fix.

avih avatar Oct 10 '22 20:10 avih

@tigerinus: If it is executed from busybox ash inside cmd.exe can it properly detect it?

ale5000-git avatar Oct 13 '22 11:10 ale5000-git

@tigerinus: If it is executed from busybox ash inside cmd.exe can it properly detect it?

It's the same issue. Something in busybox is making neovim-w32 thinking it's running under Linux like environment.

tigerinus avatar Oct 13 '22 13:10 tigerinus