[QOL] Installer/Bootstrap scripts: Better error messages
If a command fails, the installer and bootstrap scripts should output the command that failed.
Attached to this issue. Here is an example.
No liblua5.1-0-dev was available in my OS. While the bootstrap.lua is trying to install luarocks via the configure script, the error message is Vim:Configuring luarocks failed., which is confusing. However, it was just due to a library missing in the system. Thus, better error messages definitely help to make the installation easier and smoother.
While the bootstrap.lua is trying to install luarocks via the configure script, the error message is Vim:Configuring luarocks failed., which is confusing.
🤔 It should also output stderr and stdout of the configure command.
I've just tried the bootstrap script as currently included in the README. Like @zhenhua-zhang I didn't have lua development files installed, but the output is just:
Downloading luarocks...
Configuring luarocks...
Error detected while processing /home/tombh/Syncthing/SyncMisc/dotfiles/nvim-rocks/init.lua:
E5113: Error while calling lua chunk: ...h/Syncthing/SyncMisc/dotfiles/nvim-rocks//lua/_rocks.
lua:60: Vim:Configuring luarocks failed.
stack traceback:
[C]: in function 'source'
...h/Syncthing/SyncMisc/dotfiles/nvim-rocks//lua/_rocks.lua:60: in main chunk
[C]: in function 'require'
/home/tombh/Syncthing/SyncMisc/dotfiles/nvim-rocks/init.lua:3: in main chunk
Press ENTER or type command to continue
However, if I run: nvim -u ~/.cache/nvim/rocks.nvim/bootstrap.lua then I get a better error:
Downloading luarocks...
Configuring luarocks...
Error detected while processing /home/tombh/.cache/nvim/rocks.nvim/bootstrap.lua:
Configuring luarocks failed.
stderr:
stdout:
Configuring LuaRocks version 3.11.1...
Lua interpreter found: /usr/bin/luajit
Checking if /usr/bin/luajit is Lua version 5.1... yes
lua.h for Lua 5.1 not found (tried /usr/include/lua/5.1/lua.h /usr/include/lua5.1/lua.h /usr/i
nclude/lua-5.1/lua.h /usr/include/lua51/lua.h /usr/include/lua.h /usr/include/luajit-2.1/lua.h
)
If the development files for Lua (headers and libraries)
are installed in your system, you may need to use the
--with-lua or --with-lua-include flags to specify their location.
If those files are not yet installed, you need to install
them using the appropriate method for your operating system.
Run ./configure --help for details on flags.
configure failed.
E5113: Error while calling lua chunk: /home/tombh/.cache/nvim/rocks.nvim/bootstrap.lua:142: fa
iled to install luarocks! Please try again :)
stack traceback:
[C]: in function 'assert'
/home/tombh/.cache/nvim/rocks.nvim/bootstrap.lua:142: in main chunk
Press ENTER or type command to continue
I assume the second error is supposed to appear from merely using the bootstrap script?
Interesting, thanks for the insight.
I suppose vim.cmd.source truncates the error message.