Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save atelierbram/32bb42f08e1211b51ba5f80acf313520 to your computer and use it in GitHub Desktop.

Select an option

Save atelierbram/32bb42f08e1211b51ba5f80acf313520 to your computer and use it in GitHub Desktop.
Neovim symbol not found: luaopen_jsregexp

Fix: LuaSnip jsregexp "Symbol Not Found" in Neovim

When you receive the warning jsregexp library required for Placeholder-transformations in :checkhealth luasnip, the jsregexp C library needs to be compiled. On modern systems (such as Apple Silicon), this often goes wrong because the library is built for the wrong Lua version.

The Problem

Neovim uses LuaJIT, which is compatible with Lua 5.1. When you install jsregexp via a standard package manager, it is often built for Lua 5.4 or higher. This results in the error message: dlsym(... luaopen_jsregexp): symbol not found.

The Solution (Step-by-step)

  1. Compile for Lua 5.1 Use LuaRocks to build the module specifically for the Lua 5.1 ABI. This ensures that the binary symbols are compatible with Neovim.
luarocks --lua-version 5.1 install jsregexp
  1. Locate the binary file LuaRocks usually places the file in your home directory. Look for core.so:

Path: /Users/<USER>/.luarocks/lib/lua/5.1/jsregexp/core.so

  1. Create a symlink in your Neovim config Instead of modifying your package.cpath, we link the folder directly in the Neovim runtime path.

Go to your nvim lua folder cd ~/.config/nvim/lua/

Create a link to the jsregexp folder (contains core.so)

(You are at: ~/.config/nvim/lua/!)

ln -s ~/.luarocks/lib/lua/5.1/jsregexp/ ./jsregexp

  1. Create a Proxy file Because LuaSnip looks for require('jsregexp') but the binary file is named core.so (inside the jsregexp folder), we need a Lua file to bridge the gap. Create the file ~/.config/nvim/lua/jsregexp.lua with the following contents:
-- ~/.config/nvim/lua/jsregexp.lua
-- Redirects require('jsregexp') to the correctly compiled core.so
return require('jsregexp.core')

Verification

Start Neovim and run the following commands:

Direct check: :lua print(require('jsregexp'))

Result: table: 0x... (Success!)

Health check: :checkhealth luasnip

Result: OK jsregexp is installed

Why this structure?

By linking the folder and using a .lua proxy, you bypass the C-loader naming conflicts. You retain the flexibility to update the library outside your Neovim configuration via LuaRocks, while Neovim always finds the correct version.

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