Skip to content

Instantly share code, notes, and snippets.

@davidlj95
Created June 18, 2024 18:03
Show Gist options
  • Save davidlj95/ddb8ba050b3d60f42582f525db5e7245 to your computer and use it in GitHub Desktop.
Save davidlj95/ddb8ba050b3d60f42582f525db5e7245 to your computer and use it in GitHub Desktop.
LuaJIT + luarocks in macOS with brew
luarocks install --tree=$(brew --prefix)/lib/lua/5.1 luasocket
@davidlj95
Copy link
Author

davidlj95 commented Jun 18, 2024

LuaJIT + luarocks in macOS with brew

Was trying to adapt a plugin for mpv. Which uses lua via luajit under the hood (as can be seen with brew deps mpv --tree). The plugin needed libposix & libsocket lua deps to work.

Installed luarocks with brew, as seems it's the pkg manager for lua. However, luarocks installs lua at version 5.4 . Whilst mpv uses luajit. Which turns out to read packages from lua 5.1 paths.

After trying and trying, luarocks --lua-version 5.1 was installing packages in my home directory, and not in /opt/homebrew/(lib|share)/lua/5.1 where luajit expected them to be.

If installing regularly with luarocks install luaposix, they are installed to /opt/homebrew/(lib|share)/lua/5.4.

  • Using --global fails 🙃
  • Using sudo fails
  • Installing lua@5.1 and then luarocks doesn't make it work either

So the command you have there is a quirky workaround you can do to install dependencies for a brew installed luajit / lua@5.1 when using luarocks from brew.

Weird, but works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment