Tencent / LuaHelper

LuaHelper is a High-performance lua VSCode plugin, Language Server Protocol for lua.
Other
617 stars 93 forks source link

reGetSock fail后尝试require("socket.core")时提示找不到指定的模块 #125

Open cyb233 opened 2 years ago

cyb233 commented 2 years ago
Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。

尝试新的跨平台 PowerShell https://aka.ms/pscore6

PS C:\Users\Admin\Documents\vscode_project> c:/Users/Admin/.vscode/extensions/yinfei.luahelper-0.2.19/debugger/luasocket/win/x64/lua5.4/lua54.exe -e  "package.path = 'c:/Users/Admin/.vscode/extensions/yinfei.luahelper-0.2.19/debugger/?.lua;'.. package.path;  package.cpath = 'c:/Users/Admin/.vscode/extensions/yinfei.luahelper-0.2.19/debugger/luasocket/win/x64/lua5.4/?.dll;'.. package.cpath; require('LuaPanda').start('127.0.0.1',8818);" "c:/Users/Admin/Documents/vscode_project/1.lua"
[LuaPanda] [Error] reGetSock fail
[LuaPanda] [Error] Start debugger but get Socket fail , please install luasocket!
1
PS C:\Users\Admin\Documents\vscode_project> cd C:\Users\Admin\.vscode\extensions\yinfei.luahelper-0.2.19\debugger\luasocket\win\x64\lua5.4\
PS C:\Users\Admin\.vscode\extensions\yinfei.luahelper-0.2.19\debugger\luasocket\win\x64\lua5.4> .\lua54
Lua 5.4.2  Copyright (C) 1994-2020 Lua.org, PUC-Rio
> require("socket.core")
error loading module 'socket.core' from file 'C:\Users\Admin\.vscode\extensions\yinfei.luahelper-0.2.19\debugger\luasocket\win\x64\lua5.4\socket\core.dll':
        找不到指定的模块。

stack traceback:
        [C]: in ?
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: in ?
>   

image

AstroWYH commented 10 months ago

解决了吗哥

cyb233 commented 10 months ago

解决了吗哥

没有,没人回复就不用了

MarioRicalde commented 2 months ago

Solution here in another issue ( https://github.com/Tencent/LuaHelper/issues/8 ). You need to set the packagePath to include the directory.

MarioRicalde commented 2 months ago

For added clarity...

For those experiencing issues with luasocket, here's what worked for me to get the debugger working on Windows 11:

Download the Lua (5.4) Interpreter an put it somewhere to use it, in my case /C/Users/MarioRicalde/OneDrive/Documents/Lua/

Install MSYS2 https://www.msys2.org/#installation

In the MSYS terminal and install the toolchain:

pacman -S mingw-w64-x86_64-toolchain

Download latest release (src) or clone from https://github.com/lunarmodules/luasocket/releases.

Using Msys2 mingw64 and navigate to directory, adjust the paths to match your configuration (hint, replace C/Users/MarioRicalde/OneDrive/Documents with your path ):

x86_64-w64-mingw32-gcc -O2 -c -o src/luasocket.o -I/C/Users/MarioRicalde/OneDrive/Documents/Lua/include/lua/5.4 src/luasocket.c -DLUASOCKET_DEBUG -DWINVER=0x0501 -I/c/windows/system32/include
x86_64-w64-mingw32-gcc -O2 -c -o src/timeout.o -I/C/Users/MarioRicalde/OneDrive/Documents/Lua/include/lua/5.4 src/timeout.c -DLUASOCKET_DEBUG -DWINVER=0x0501 -I/c/windows/system32/include
x86_64-w64-mingw32-gcc -O2 -c -o src/buffer.o -I/C/Users/MarioRicalde/OneDrive/Documents/Lua/include/lua/5.4 src/buffer.c -DLUASOCKET_DEBUG -DWINVER=0x0501 -I/c/windows/system32/include
x86_64-w64-mingw32-gcc -O2 -c -o src/io.o -I/C/Users/MarioRicalde/OneDrive/Documents/Lua/include/lua/5.4 src/io.c -DLUASOCKET_DEBUG -DWINVER=0x0501 -I/c/windows/system32/include
x86_64-w64-mingw32-gcc -O2 -c -o src/auxiliar.o -I/C/Users/MarioRicalde/OneDrive/Documents/Lua/include/lua/5.4 src/auxiliar.c -DLUASOCKET_DEBUG -DWINVER=0x0501 -I/c/windows/system32/include
x86_64-w64-mingw32-gcc -O2 -c -o src/options.o -I/C/Users/MarioRicalde/OneDrive/Documents/Lua/include/lua/5.4 src/options.c -DLUASOCKET_DEBUG -DWINVER=0x0501 -I/c/windows/system32/include
x86_64-w64-mingw32-gcc -O2 -c -o src/inet.o -I/C/Users/MarioRicalde/OneDrive/Documents/Lua/include/lua/5.4 src/inet.c -DLUASOCKET_DEBUG -DWINVER=0x0501 -I/c/windows/system32/include
x86_64-w64-mingw32-gcc -O2 -c -o src/except.o -I/C/Users/MarioRicalde/OneDrive/Documents/Lua/include/lua/5.4 src/except.c -DLUASOCKET_DEBUG -DWINVER=0x0501 -I/c/windows/system32/include
x86_64-w64-mingw32-gcc -O2 -c -o src/select.o -I/C/Users/MarioRicalde/OneDrive/Documents/Lua/include/lua/5.4 src/select.c -DLUASOCKET_DEBUG -DWINVER=0x0501 -I/c/windows/system32/include
x86_64-w64-mingw32-gcc -O2 -c -o src/tcp.o -I/C/Users/MarioRicalde/OneDrive/Documents/Lua/include/lua/5.4 src/tcp.c -DLUASOCKET_DEBUG -DWINVER=0x0501 -I/c/windows/system32/include
x86_64-w64-mingw32-gcc -O2 -c -o src/udp.o -I/C/Users/MarioRicalde/OneDrive/Documents/Lua/include/lua/5.4 src/udp.c -DLUASOCKET_DEBUG -DWINVER=0x0501 -I/c/windows/system32/include
x86_64-w64-mingw32-gcc -O2 -c -o src/compat.o -I/C/Users/MarioRicalde/OneDrive/Documents/Lua/include/lua/5.4 src/compat.c -DLUASOCKET_DEBUG -DWINVER=0x0501 -I/c/windows/system32/include
x86_64-w64-mingw32-gcc -O2 -c -o src/wsocket.o -I/C/Users/MarioRicalde/OneDrive/Documents/Lua/include/lua/5.4 src/wsocket.c -DLUASOCKET_DEBUG -DWINVER=0x0501 -I/c/windows/system32/include
mkdir socket
x86_64-w64-mingw32-gcc  -shared -o socket/core.dll src/luasocket.o src/timeout.o src/buffer.o src/io.o src/auxiliar.o src/options.o src/inet.o src/except.o src/select.o src/tcp.o src/udp.o src/compat.o src/wsocket.o -lws2_32 /C/Users/MarioRicalde/OneDrive/Documents/Lua/lua54.dll -lm

With that you should have the core.dll file:

MarioRicalde@MR-WS MINGW64 /c/Users/MarioRicalde/OneDrive/Documents/Lua/other/luasocket-3.1.0
$ ls socket
core.dll

Go to VSCode, Ctrl + P, write:

LuaHelper: Open Debug Folder

That will open explorer, go into luasocket > win > x64 > lua5.4 > socket

Rename core.dll to core.bak.dll and add your newly compiled core.dll

Go back into VSCode and test.