Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install jsregexp (OS: Windows) #1220

Open
hrcHarry opened this issue Aug 6, 2024 · 10 comments
Open

Unable to install jsregexp (OS: Windows) #1220

hrcHarry opened this issue Aug 6, 2024 · 10 comments

Comments

@hrcHarry
Copy link

hrcHarry commented Aug 6, 2024

Hi, I have checked #569 but I have a slightly different situation.

OS: Windows 10
Neovim Version:
NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1713484068

The installation of Luasnip via Lazy gives the following message

git submodule init
process_begin: CreateProcess(NULL, uname, ...) failed.
process_begin: CreateProcess(NULL, pwd, ...) failed.
process_begin: CreateProcess(NULL, pwd, ...) failed.
git submodule update
make "CC=cc" "INCLUDE_DIR=-I'/deps/lua51_include/'" LDLIBS="" -C "deps/jsregexp"
make[1]: Entering directory `C:/Users/User/AppData/Local/nvim-data/lazy/LuaSnip/deps/jsregexp'
cc -I'/deps/lua51_include/' -O2 -fPIC -c jsregexp.c -o jsregexp.o
process_begin: CreateProcess(NULL, cc -I/deps/lua51_include/ -O2 -fPIC -c jsregexp.c -o jsregexp.o, ...) failed.

make[1]: *** [jsregexp.o] Error 2
make[1]: Leaving directory `C:/Users/User/AppData/Local/nvim-data/lazy/LuaSnip/deps/jsregexp'
make: *** [jsregexp] Error 2

Additional info:
I have installed gcc, g++, zig, and clang (Visual Studio) is installed on my machine before installing Luasnip.

Could anyone help? Thanks.

@JohnWilliston
Copy link

I have the very same issue with a clean install of Neovim and clean pull of the plugin.

@JohnWilliston
Copy link

JohnWilliston commented Oct 25, 2024

Wow. And at the end of the day, it doesn't make one whit of difference. I finally fought through all the nonsense necessary to get the make files and everything building without errors in the right directory and everything. The following screenshot is of me using the MSYS2 UCRT64 command window to do an uninstall and a reinstall in the very LuaSnip folder:

2024-10-24 19_40_35-_c_Users_John_AppData_Local_nvim-data_lazy_LuaSnip

The jsregexp.so file builds just fine and copies to deps/luasnip-jsregexp.so just fine. I can copy both of those *.so files to my nvim/lua folder or anywhere else, but checking health still complains that the jsregexp library is not installed. I seriously don't know how to make this thing happy.

@JohnWilliston
Copy link

JohnWilliston commented Oct 26, 2024

For anyone following this thread, or other other threads about the difficulties of getting jsregexp working with Luasnip on Windows, I posted a reply today on one of the jsregexp issues that explains how I eventually got it working. I hope it might prove useful to others as a guide what not to do and what to do as well.

@xudyang1
Copy link
Contributor

Please have a try for the fix #1252

@zeratax
Copy link

zeratax commented Dec 23, 2024

Having a lot of troubles with the makefile

PROJECT_ROOT:=$(shell pwd 2>/dev/null)

I replaced that with $(CURDIR) otherwise PROJECT_ROOT just evaluated to "".

LUA_LDLIBS?=$(if $(strip $(NEOVIM_BIN_PATH)),-L$(NEOVIM_BIN_PATH) -llua51,)

and I replaced this with LUA_LDLIBS?=$(if $(strip $(NEOVIM_BIN_PATH)),-L$("NEOVIM_BIN_PATH") -llua51,), note the quotation marks otherwise it struggled with the space in "Program Files"

error: unable to find dynamic system library 'lua51' using strategy 'paths_first'. searched paths:
  C:\Program\lua51.dll
  C:\Program\lua51.lib
  C:\Program\liblua51.a

that got it to run the makefile in powershell and msys.

also it doesnt seem to work with llvm but only gcc? otherwise i still get linking errors.

and yeah then it still doesnt do anything just like @JohnWilliston said

@xudyang1
Copy link
Contributor

xudyang1 commented Jan 2, 2025

Having a lot of troubles with the makefile

PROJECT_ROOT:=$(shell pwd 2>/dev/null)

I replaced that with $(CURDIR) otherwise PROJECT_ROOT just evaluated to "".

LUA_LDLIBS?=$(if $(strip $(NEOVIM_BIN_PATH)),-L$(NEOVIM_BIN_PATH) -llua51,)

and I replaced this with LUA_LDLIBS?=$(if $(strip $(NEOVIM_BIN_PATH)),-L$("NEOVIM_BIN_PATH") -llua51,), note the quotation marks otherwise it struggled with the space in "Program Files"

error: unable to find dynamic system library 'lua51' using strategy 'paths_first'. searched paths:
  C:\Program\lua51.dll
  C:\Program\lua51.lib
  C:\Program\liblua51.a

that got it to run the makefile in powershell and msys.

also it doesnt seem to work with llvm but only gcc? otherwise i still get linking errors.

and yeah then it still doesnt do anything just like @JohnWilliston said

How do you install LuaSnip and do you use any package manager? I have tested locally on powershell 7.4.6 and git bash, both worked fine.

@JohnWilliston
Copy link

How do you install LuaSnip and do you use any package manager? I have tested locally on powershell 7.4.6 and git bash, both worked fine.

For my part, I use the following luasnip.lua file in my nvim/lua/plugins folder if that helps:

return {
    "L3MON4D3/LuaSnip",
    -- follow latest release.
    -- version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
    -- install jsregexp (optional!).
    build = "make install_jsregexp",
    dependencies = {
        "saadparwaiz1/cmp_luasnip",
        "rafamadriz/friendly-snippets",
    },
    config = function()

        local ls = require("luasnip")

        local t = ls.text_node
        local i = ls.insert_node
        local f = ls.function_node
        local s = ls.snippet
        local l = require("luasnip.extras").lambda

        -- args is a table, where 1 is the text in Placeholder 1, 2 the text in
        -- placeholder 2,...
        local function copy(args)
            return args[1]
        end

        ls.add_snippets("all", {
            -- trigger is `fn`, second argument to snippet-constructor are the nodes to insert into the buffer on expansion.
            s("fn", {
                -- Simple static text.
                t("//Parameters: "),
                -- function, first parameter is the function, second the Placeholders
                -- whose text it gets as input.
                f(copy, 2),
                t({ "", "function " }),
                -- Placeholder/Insert.
                i(1),
                t("("),
                -- Placeholder with initial text.
                i(2, "int foo"),
                -- Linebreak
                t({ ") {", "\t" }),
                -- Last Placeholder, exit Point of the snippet.
                i(0),
                t({ "", "}" }),
            }),

            s("transform", {
                i(1, "initial text"),
                t({ "", "" }),
                -- lambda nodes accept an l._1,2,3,4,5, which in turn accept any string transformations.
                -- This list will be applied in order to the first node given in the second argument.
                l(l._1:match("[^i]*$"):gsub("i", "o"):gsub(" ", "_"):upper(), 1),
            }),
        }, {
            key = "all",
        })

        require("luasnip.loaders.from_vscode").lazy_load()

    end,
}

@xudyang1
Copy link
Contributor

xudyang1 commented Jan 7, 2025

@JohnWilliston If you are using make with gcc, the following may work

local IN_WINDOWS = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1
return {
  "L3MON4D3/LuaSnip",
  build = IN_WINDOWS and "make install_jsregexp CC=gcc" or "make install_jsregexp",
  -- more ...
}
  • If it does not work, please check:
  1. which sh.exe points to Git/MinGW/MSYS2 sh.exe
  • if empty, append SHELL=C:/path/to/Git/usr/bin/sh.exe after make install_jsregexp
  1. which cc points to a compiler
  • if empty, append CC=gcc after make install_jsregexp

@xudyang1
Copy link
Contributor

xudyang1 commented Jan 7, 2025

@zeratax llvm should also work. You can try make install_jsregexp CC=clang

@JohnWilliston
Copy link

I appreciate the attempts to help, thank you. I've moved on after finding the workaround I linked above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants