I'm using MacVim snapshot 134 (on Mac OS X 10.9.5), which has support for Lua:

$ vim --version | grep lua
+dialog_con_gui  +lua/dyn         +rightleft       +writebackup

I've got Lua installed and can even run it as an external command from within Vim:

Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio
> print("hello")

However,has("lua") returns 0:

:echo has("lua")

And attempting to use it through Vim's interface fails:

:lua print("hello")
E370: Could not load library liblua.5.2.dylib
Lua library cannot be loaded.

How can I get Vim to properly detect Lua? Is this a case of extremely strict required version matching, such that 5.2 means 5.2 period and 5.3.3 is not good enough?

I did notice this question over on SO, but that doesn't seem to help, as all the answers say to install a version of Vim with +lua/dyn, which I already have.

2 Answers 2


Yes, you Vim was compiled in such a way, that Vim will be looking for the dynamic library liblua5.2.dylib. If Vim cannot find that library, it obviously cannot use the lua extension.

This however is independent of usine :!lua which will shell out to the lua binary and run that command. For that, you do not need to compile Vim with +lua you just need to have a lua binary in your path, but that obviously cannot make use of the provided VimScript API.

If your system only provides a liblua5.3 library, you either have to compile Vim yourself with that library, or install additionally the liblua5.2 library in addition to the existing system wide library.


Christian Brabandt is correct, Vim requires the exact same version it was compiled for.

In my case, however, Vim still failed to load liblua.5.2.dylib even after installing Lua 5.2. I fixed that by adding a line to my .vimrc to explicitly tell Vim where to look:

set luadll=/path/to/liblua.5.2.dylib

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.