distant.nvim icon indicating copy to clipboard operation
distant.nvim copied to clipboard

Windows 10 [not wsl] Rust library not found

Open mr-majkel opened this issue 4 years ago • 13 comments

Hi, I have installed distant.nvim with Plug, and even though the binary works, distant.nvim seems not able to locate the dll:

:DistantSystemInfo
Rust library not found! What would you like to do?
1. Download a prebuilt lib
2. Build from source
3. Copy local lib
Type number and <Enter> or click with the mouse (q or empty cancels):

I have tried 1 and 3 with no success. I have downloaded distant_lua-win64.dll, renamed it to distant_lua.dll, and put it in the binary location, as well as in the {plugins_folder}/distant.nvim/lua/.

mr-majkel avatar Nov 05 '21 10:11 mr-majkel

@mr-majkel what do you see when you run lua print(package.cpath)? Windows lacks full testing as I don't have a machine to verify end-to-end. From my readings, the path should include dlls. On my Mac, you see something like the following for *.so files: ./?.so;/usr/local/lib/lua/5.1/?.so;/opt/homebrew/Cellar/luajit-openresty/2.1-20210510/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so;/Users/senkwic h/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so

chipsenkbeil avatar Nov 06 '21 00:11 chipsenkbeil

Here is the output

.\?.dll;C:\Users\mr_majkel\AppData\Local\Programs\Neovim\bin\?.dll;C:\Users\mr_majkel\AppData\Local\Programs\Neovim\bin\loadall.dll

I have tried to put the dll to Neovim\bin but still getting the same result.

mr-majkel avatar Nov 09 '21 12:11 mr-majkel

We show the prompt when there's an error loading the library. This is normally because the library isn't found, but in this case maybe there's an error loading the library for another reason. ~~Can you open up lua/distant/lib.lua at line 551 and modify the next couple of lines to look like this?~~

local success, lib = pcall(require, LIB_NAME)
if success then
    return cb(success, lib)
else
    -- Print out an error when we fail to load our library
    vim.api.nvim_err_writeln('Failed to load lib: ' .. tostring(lib))
end

chipsenkbeil avatar Nov 10 '21 18:11 chipsenkbeil

@mr-majkel actually, ignore my rec from above. I've pushed a new commit that should report the error if the library exists but fails to load. Grab https://github.com/chipsenkbeil/distant.nvim/commit/1d798b3746709ee5b1a2209d63248800cea82f09 and let me know what error you see.

chipsenkbeil avatar Nov 10 '21 19:11 chipsenkbeil

Hi @chipsenkbeil, here is the output:

vim.lua:80: The specified module could not be found.^M
error loading module 'distant_lua' from file 'C:\Users\mr_majkel\AppData\Local\Programs\Neovim\bin\distant_lua.dll':
^IThe specified module could not be found.^M
vim.lua:80: The specified module could not be found.^M
error loading module 'distant_lua' from file 'C:\Users\mr_majkel\AppData\Local\Programs\Neovim\bin\distant_lua.dll':
^IThe specified module could not be found.^M

Press ENTER or type command to continue

mr-majkel avatar Nov 11 '21 17:11 mr-majkel

@mr-majkel as a heads up, your issues with the Rust library being loaded are not the only downsides I've seen of this approach. I'm planning to switch back to having vim talk to the distant binary instead, which will remove problems like this.

The main thing you can test for me right now is that distant listen works for you with the cli program, even if you just use it to listen on your local machine. Windows doesn't support unix-like forking, so I had to do it another way which may or may not work as it hasn't been verified. I know that distant listen --foreground would work for you on Windows, but that isn't what we want to do most of the time.

Otherwise, keep an eye out as I'll be trying to get the changes to this plugin done over this weekend and next.

chipsenkbeil avatar Nov 12 '21 17:11 chipsenkbeil

@chipsenkbeil In distant CI you build module for Windows using the following configuration: https://github.com/chipsenkbeil/distant/blob/master/.github/workflows/ci-windows.yml

        env:
          LUA_INC: ${{ github.workspace }}\.lua\include
          LUA_LIB: ${{ github.workspace }}\.lua\lib
          LUA_LIB_NAME: lua

which links module to lua.dll that not present in Neovim for Windows. It has lua51.dll. After linking to lua51 it works fine.

khvzak avatar Nov 15 '21 19:11 khvzak

@mr-majkel try using version 0.15.1 of the Windows dll. You can pull it in like usual with DistantInstall to see if it fixes the loading problem.

chipsenkbeil avatar Nov 16 '21 03:11 chipsenkbeil

@chipsenkbeil no luck. The error is the same for running :DistantLaunch in nvim with distant 0.15.1 and accompanying dll, and the plugin updated.

The main thing you can test for me right now is that distant listen works for you with the cli program, even if you just use it to listen on your local machine. Windows doesn't support unix-like forking, so I had to do it another way which may or may not work as it hasn't been verified. I know that distant listen --foreground would work for you on Windows, but that isn't what we want to do most of the time.

I can confirm that running listen in cli seems to work - the process is visible in the Windows' Task Manager.

$ distant listen
INFO [distant::subcommand::listen] [distant detached, pid = 13096]

DISTANT CONNECT -- 8080 cb9ff9bd7d0e2a1b4566b9a0e98d61713dbdf7f8d5dbb2c8583fe764a13496e5

However when I try to run distant launch -p 8080 localhost the cli seems frozen. C-c terminates the call without any message.

mr-majkel avatar Nov 17 '21 09:11 mr-majkel

Unfortunately distant v0.15.1 for Windows is still requires lua.dll :(

khvzak avatar Nov 17 '21 18:11 khvzak

Unfortunately distant v0.15.1 for Windows is still requires lua.dll :(

Hm, I thought changing LUA_LIB_NAME to lua51 would do that for me?

However when I try to run distant launch -p 8080 localhost the cli seems frozen. C-c terminates the call without any message.

This is the expected behavior when running in the foreground, but not what I'd expect for windows by default. I'm going to need to add some e2e tests somehow to verify behavior.

I can confirm that running listen in cli seems to work - the process is visible in the Windows' Task Manager.

Does distant listen exit and have another process running in the background? Or does it persist in the foreground?

chipsenkbeil avatar Nov 17 '21 19:11 chipsenkbeil

@chipsenkbeil LUA_LIB_NAME only sets which .lib file to use (it controls -l option for linker). DLL library name is defined inside that lib file for dynamic linking (as I understand how it works on Windows). Apparently this is how xpol/[email protected] configured. Could you try to use https://github.com/leafo/gh-actions-lua instead ?

Unfortuantely I cannot yet build distant on Windows using alternatnative Lua, it fails to build openssl-sys dependency using the msvc compiler. Seems I do something wrong, don't have much experience with Windows.

Upd: distant module loads on Windows in vanialla lua 5.1 if copy lua51.dll to lua.dll

khvzak avatar Nov 17 '21 20:11 khvzak

Upd: distant module loads on Windows in vanialla lua 5.1 if copy lua51.dll to lua.dll

@khvzak @chipsenkbeil I can confirm that this work-around works for me. Now I just need to setup lsp for my projects on the remote;).

mr-majkel avatar Dec 03 '21 09:12 mr-majkel

I'm having the same rust library not found on my macos 13.2.1, any help?

geohuz avatar Mar 27 '23 15:03 geohuz

I'm having the same rust library not found on my macos 13.2.1, any help?

geohuz avatar Mar 27 '23 15:03 geohuz

@geohuz can you try using the v0.2 branch of distant.nvim instead? It's much more up-to-date and is going to be used as the primary branch soon.

chipsenkbeil avatar Mar 27 '23 17:03 chipsenkbeil

@chipsenkbeil I managed to fix the issue and now only one thing left, that I can't open file from directory navigation by press return key, I tried 0.2 tag the problem still there, I can only open the file by specifying the full direction of the file. I'm not sure if this is relate to the Lunarvim.

geohuz avatar Mar 28 '23 07:03 geohuz

Closing out as an outdated issue for v0.2. With v0.3 being the new branch, feel free to open a new issue against it if this is still a problem.

chipsenkbeil avatar Aug 26 '23 22:08 chipsenkbeil