iamcco / markdown-preview.nvim

markdown preview plugin for (neo)vim
MIT License
6.75k stars 280 forks source link

Markdownpreview, pre build and node is not found #225

Open ebinhua opened 4 years ago

ebinhua commented 4 years ago

WIN10,MSYS2 vim 8.1 ,When I run :Markdownpreview, there is a error message:"[vim-node-rpc] pre build and node not found!"pre build and node not found afterrun :call mkdp#util#install() it show install complete but when run : markdownpreview, it still with pre build and node is not found

iamcco commented 4 years ago

Seems the pre build bundle can not execute for your system.

KaffeMyers commented 2 years ago

Having the same issue here. How would I go about troubleshooting this?

zhenggennj commented 1 year ago

The Cause

It is the complex environments on platform msys2 that causes the issue.

There are 6 environments in msys2, each represented by a terminal:

No Terminal
Name
bin,lib,man
prefix
Toolchain Architecture C Library C++ Library
1 MSYS /usr gcc x86_64 cygwin libstdc++
2 UCRT64 /ucrt64 gcc x86_64 ucrt libstdc++
3 CLANG64 /clang64 llvm x86_64 ucrt libc++
4 CLANG32 /clang32 llvm i686 ucrt libc++
5 MINGW64 /mingw64 gcc x86_64 msvcrt libstdc++
6 MINGW32 /mingw32 gcc i686 msvcrt libstdc++

Pay attension to the 3rd column. If one switches between terminals, the prefixes of bin, lib and man are switched also. That means each environment has different PATH content.

Terminal Name part of PATH
MSYS /usr/bin
UCRT64 /ucrt64/bin:/usr/bin
CLANG64 /clang64/bin:/usr/bin
CLANG32 /clang32/bin:/usr/bin
MINGW64 /mingw64/bin:/usr/bin
MINGW32 /mingw32/bin:/usr/bin

Open a "MSYS2 MINGW32" terminal from START menu, exec "which" in the following way:

mpi@AcerWin10 MINGW32 ~
$ which vim
/usr/bin/vim

mpi@AcerWin10 MINGW32 ~
$ which node
/mingw32/bin/node

It is found that the executable vim is installed for terminal "msys" and the executable node is for terminal "mingw32". Although the current terminal is 'mingw32', vim is accessible since phrase /usr/bin is present in all other 5 PATHs. If one would reproduce the issue, he could do in the following way:

  1. Launch terminal "MSYS2 MSYS" from START menu
  2. Open a md document, say imgtest.md, using vim: vim imgtest.md
  3. Emit MarkdownPreview command in vim : :MarkdownPreview
  4. The message "pre build and node is not found" will appear

Now check the location of the executables:

mpi@AcerWin10 MSYS ~/md_write
$ which vim
/usr/bin/vim

mpi@AcerWin10 MSYS ~/md_write
$ which node
which: no node in (/mingw32/ITURHFProp/bin:/C/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86:/home/mpi/.local/bin:/C/Program Files (x86)/Microsoft/Edge/Application:/C/Program Files/Google/Chrome/Application/:/usr/local/bin:/usr/bin:/bin:/opt/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)

This is the reason of this issue. After switching the terminal from mingw32 to msys, phrase /mingw32/bin is absent from PATH and thus the executable node can not be found.

Package availability

packman

The package managing tool is pacman on MSYS2. It is installed for all environments:

mpi@AcerWin10 MINGW32 ~/md_write
$ which pacman
/usr/bin/pacman

nodejs

The following is the query results for package nodejs(irrelavant lines are removed)

mpi@AcerWin10 MINGW32 ~
$ pacman -sS nodejs
mingw32/mingw-w64-i686-nodejs 18.15.0-1 [已安装]
mingw64/mingw-w64-x86_64-nodejs 18.15.0-1
ucrt64/mingw-w64-ucrt-x86_64-nodejs 18.15.0-1 [已安装]
clang32/mingw-w64-clang-i686-nodejs 18.15.0-1
clang64/mingw-w64-clang-x86_64-nodejs 18.15.0-1

The package nodejs is available for all terminals except msys. A package, e.g. mingw-w64-i686-nodejs, can be installed using command pacman -S mingw-w64-i686-nodejs. The executable node will be put into /mingw32/bin. Other packages are installed in the same manner. Executables with the same name node will be put into respective folders.

vim

The following is the query results for package vim:

mingw64/mingw-w64-x86_64-neovim 0.9.0-1
ucrt64/mingw-w64-ucrt-x86_64-neovim 0.9.0-1 [已安装]
clang64/mingw-w64-clang-x86_64-neovim 0.9.0-1
msys/vim 9.0.1403-1 (editors) [已安装]

vim is available only for msys. Package neovim is available only for mingw64, ucrt64 and clang64.

python and pip

The following is the query results for package python:

mingw32/mingw-w64-i686-python 3.10.11-1 [已安装]
mingw64/mingw-w64-x86_64-python 3.10.11-1 [已安装]
ucrt64/mingw-w64-ucrt-x86_64-python 3.10.11-1 [已安装]
clang32/mingw-w64-clang-i686-python 3.10.11-1
clang64/mingw-w64-clang-x86_64-python 3.10.11-1
msys/python 3.11.2-1 [已安装]

python is available for all terminals. Note that the version of msys/python is different from those of others.

The following is the query results for package pip:

mingw32/mingw-w64-i686-python-pip 23.1-1 [已安装]
mingw64/mingw-w64-x86_64-python-pip 23.1-1
ucrt64/mingw-w64-ucrt-x86_64-python-pip 23.1-1 [已安装]
clang32/mingw-w64-clang-i686-python-pip 23.1-1
clang64/mingw-w64-clang-x86_64-python-pip 23.1-1
msys/python-pip 23.0.1-1 [已安装]

python-pip is also available for all terminals. Note that the version of msys/python-pip is also different from those of others.

One must keep a clear mind about which pip/python will be invoked on which terminal. Otherwise he will run into trouble. The rule of thumb: always switch to msys terminal to install python packages for vim since there is a binding between msys/vim and msys/python 3.11 in building phase and msys/vim will always use python packages from msys/python 3.11 installation.