Skip to content
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

Msys vim's executable() can't find programs despite them being add in the PATH #14823

Closed
ykhan21 opened this issue May 21, 2024 · 10 comments
Closed
Labels

Comments

@ykhan21
Copy link

ykhan21 commented May 21, 2024

Steps to reproduce

  1. On Windows, install msys (https://www.msys2.org/).
  2. Install the scoop package manager (https://scoop.sh/) on Windows (not in an msys environment).
  3. Install fzf with scoop (scoop install fzf) on Windows (not in an msys environment).
  4. Open an msys ucrt terminal by typing ucrt in the Windows search bar. This will start bash.
  5. Use pacman to upgrade vim.
  6. Open another terminal with regular Windows cmd.exe.
  7. Observer that fzf is found in cmd but not bash.
  8. Add ~/scoop/shims to the PATH variable in ~/.bashrc (in the ucrt terminal). Source the ~/.bashrc file in bash.
  9. Observe that you can now find fzf in bash. which fzf should return /c/Users/KhanY_z23jg7i/scoop/shims/fzf.
  10. Start vim in bash.
  11. Run :echo executable('fzf'). Observer that vim can't find fzf despite it being added to the path.
  12. Add `set rtp+=~/scoop/shims' to the .vimrc and source it.
  13. Observe that :echo executable('fzf') still can't find fzf.

Expected behaviour

Vim in msys should be able to find executables present in the PATH environment variable or in the vim runtimepath.

This is strange because Git Bash's vim can find fzf from the PATH variable (without it being added to the runtimepath).

Git Bash's (https://git-scm.com/download/win) vim version: 9.1.264
Msys's vim version: 9.1.380

Version of Vim

9.1.380

Environment

OS: Windows
Environment: msys
TERM: xterm
Shell: bash

Logs and stack traces

No response

@ykhan21 ykhan21 added the bug label May 21, 2024
@Konfekt
Copy link
Contributor

Konfekt commented May 21, 2024

Fzf can be found in Vim in Git Bash so that I wonder what the difference to MSYS2 vim is.
Confusingly, at the end Git Bash's vim is mentioned, but MSYS(2) has to be installed.
Would it not help to have the outputs of %PATH% respectively $PATH, in particular in Vim?

@Konfekt
Copy link
Contributor

Konfekt commented May 21, 2024

Vim in msys should be able to find executables present in the PATH environment variable

Or does this imply that $PATH in Vim in MSYS(2) was checked to be the same as in Vim in Git Bash?

@Konfekt
Copy link
Contributor

Konfekt commented May 21, 2024

There's a some conversion to include%PATH% into $PATH, so maybe that's where the difference lies. Git Bash Vim is a more common setup than MSYS Vim, so perhaps some path in %PATH% is amiss?

@ykhan21
Copy link
Author

ykhan21 commented May 21, 2024

Confusingly, at the end Git Bash's vim is mentioned, but MSYS(2) has to be installed.

Git Bash (GB) doesn't need to be installed. I was just noting that Git Bash's vim is able to pick up fzf because GB's vim, which seems to be a discrepancy as MSYS's vim and GB's vim are both compiled under MSYS.

Or does this imply that $PATH in Vim in MSYS(2) was checked to be the same as in Vim in Git Bash?

There's a some conversion to include%PATH% into $PATH, so maybe that's where the difference lies. Git Bash Vim is a more common setup than MSYS Vim, so perhaps some path in %PATH% is amiss?

GB's $PATH will inherit from Window's %PATH%. MSYS's $PATH will not.

When I installed scoop on Windows, scoop added the scoop\shims directory to the Windows %PATH%, causing it to automatically appear in the Git Bash $PATH.

However, I have added the ~/scoop/shims scoop directory to the $PATH in the ~/.bashrc file by adding the line export PATH=$PATH:"~/scoop/shims".

This worked to make MSYS's bash aware of fzf, but not MSYS's vim.

Would it not help to have the outputs of %PATH% respectively $PATH, in particular in Vim?
:echo %PATH% in vim returns:

E15: Invalid expression: "%PATH%"

:echo $PATH in MSYS's vim:

/ucrt64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/
Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:
~/scoop/shims:~/scoop/shims:~/scoop/shims

:echo $PATH in GB's vim:

/c/Users/username/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/username/bin:/c/Program Files (x86)/VMware/VMware Player/bin:/c/Program Files (x86)/Intel/Intel(R) M
anagement Engine Components/iCLS:/c/Program Files/Intel/Intel(R) Management Engine Components/iCLS:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Wind
ows/System32/OpenSSH:/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/c/Program Files (x86)/Intel/Intel(R) Management
 Engine Components/IPT:/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WIN
DOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/c/Program Files/dotnet:/c/ProgramData/chocolatey/bin:/c/Program Files (x86)/gnupg/bin:/c
/Program Files/Amazon/AWSCLIV2:/c/Program Files/Amazon/AWSSAMCLI/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Progra
m Files/Go/bin:/c/Program Files/nodejs:/c/Program Files/Docker/Docker/resources/bin:/c/Program Files/Cloudflare/Cloudflare WARP:/c/Users/username/scoop/apps/mpv/current:/c/Users/username/AppData/
Local/Programs/Python/Python312/Scripts:/c/Users/username/AppData/Local/Programs/Python/Python312:/c/Users/username/scoop/apps/gsudo/current:/c/Users/username/scoop/apps/imagemagick/current:
/c/Users/username/scoop/apps/maven/current/bin:/c/Users/username/scoop/apps/latex/current/texmfs/install/miktex/bin/x64:/c/Users/username/scoop/apps/ant/current/bin:/c/Users/username/.p
yenv/pyenv-win/bin:/c/Users/username/.pyenv/pyenv-win/shims:/c/Users/username/scoop/shims:/c/Users/username/AppData/Local/Microsoft/WindowsApps:/c/Program Files (x86)/SSH Communications Secu
rity/SSH Secure Shell:/c/Program Files/JetBrains/IntelliJ IDEA Community Edition 2020.3.1/bin:/c/Users/username/.dotnet/tools:/c/Program Files/multimonitortool-x64:/c/Program Files/nvim-win64:/c/tools
/neovim/nvim-win64/bin:/c/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin:/c/Program Files/KeePassXC:/c/Users/username/go/bin:/c/Program Files/SumatraPDF:/c/ProgramData/nvm:/c/Program Files
/nodejs:/c/Users/username/AppData/Local/Coursier/cache/arc/https/github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u292-b10/OpenJDK8U-jdk_x64_windows_hotspot_8u292b10.zip/jdk8u292-b10/bi
n:/c/Users/username/AppData/Local/Coursier/data/bin:/c/Users/username/AppData/Local/Microsoft/WindowsApps:/c/Program Files/JetBrains/IntelliJ IDEA Community Edition 2023.2.4/bin:/c/Users/KhanY_z2
3jg7i/AppData/Local/Programs/oh-my-posh/bin:/c/Program Files/Neovim/bin:/c/Users/username/go/bin:/c/Users/username/AppData/Roaming/npm:/c/Users/username/programs:/c/Users/username/progr
ams/pgsql/bin:/c/Users/username/.jdks/openjdk-17.0.2/bin:/c/Users/username/AppData/Local/Programs/Microsoft VS Code/bin:/c/users/khany_z23jg7i/.local/bin:/c/Users/username/programs/focus:/c/
Users/username/programs/ctags:/usr/bin/vendor_perl:/usr/bin/core_perl:~/scoop/shims:~/scoop/shims

@Konfekt
Copy link
Contributor

Konfekt commented May 21, 2024

You might have better chances with export PATH=$PATH:"$USERPROFILE/scoop/shims" in ~/.bashrc (or $HOME).
If neither $USERPROFILE, nor $HOME, then /c/Users/username.
Maybe let $BASH_ENV = $HOME.'/.bashrc is needed as well.
By the way, I thought rather ~/.bash_profile than ~/.bashrc to be read by Git Bash MSYS2, so maybe also MSYS2 itself?

@ykhan21
Copy link
Author

ykhan21 commented May 21, 2024

When I add the export ~/.bashrc, MSYS picks it up fine as evidenced by which fzf in MSYS. However, MSYS vim's executable() function does not pick it up.

I will try the other PATH recommendations and report back later.

@benknoble
Copy link
Contributor

It looks like tilde-expansion was not performed in the broken case; compare ~/scoops/shim with c:/users/username/scoops/shim

@Konfekt
Copy link
Contributor

Konfekt commented May 22, 2024

Yes, in terms of robustness: /c/Users/username > $HOME/USERPROFILE > ~/, from experience.

@ykhan21
Copy link
Author

ykhan21 commented May 22, 2024

Thanks. /c/users/username, $HOME, and $USERPROFILE worked as opposed to the ~.

@chrisbra
Copy link
Member

So I guess this is not a Vim issue but rather a bash/msys particularity. Let's close it then.

@chrisbra chrisbra closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants