LuaLS / LuaLS/lua-language-server

search path is not change for the require command whn i configure the relative extension's paths

Open
#2,398 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

### How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

### Which OS are you using?

Linux

### What is the issue affecting?

Libraries

### Expected Behaviour

I wrote the following code:
`local cjson = require 'posix.unistd'
print(type(cjson))
a = {}
print("aaaa")
from command line it is running perfectly
my LUA_PATH = `/usr/local/share/lua/5.4/?.lua;/usr/local/share/lua/5.4/?/init.lua;/usr/local/lib/lua/5.4/?.lua;/usr/local/lib/lua/5.4/?/init.lua;./?.lua;./?/init.lua
my LUA_CPATH = /usr/local/lib/lua/5.4/?.so;/usr/local/lib/lua/5.4/loadall.so;./?.so
LUA Runtime setting for the extension is as:
```
?.lua
?/init.lua
/usr/local/share/lua/5.4/?.lua;
/usr/local/share/lua/5.4/?/init.lua;
/usr/local/lib/lua/5.4/?.lua;
/usr/local/lib/lua/5.4/?/init.lua;
./?.lua;
./?/init.lua
```
LUA workspace library
/usr/local/lib/lua/5.4/?.so;
/usr/local/lib/lua/5.4/loadall.so;
./?.so
when i am running or debugging the program it still searches the workspace folder, any suggestion?

### Actual Behaviour

It should change the searching directory prior running to .so paths

### Reproduction steps

1. Go to '...'
2. code editor
3. write an include statement
4. Click '...'
5. run or debug
6. See error '...'
7. `module 'posix.unistd' not found:
no field package.preload['posix.unistd']
no file '/home/konstantinos/Desktop/server/lua-apps/posix/unistd.lua'
no file '/home/konstantinos/Desktop/server/lua-apps/posix/unistd.lua'
no file '/home/konstantinos/Desktop/server/lua-apps/posix/unistd.so'
no file '/home/konstantinos/Desktop/server/lua-apps/posix/unistd.so'
no file '/home/konstantinos/Desktop/server/lua-apps/posix.so'
no file '/home/konstantinos/Desktop/server/lua-apps/posix.so'`

### Additional Notes

error loading module 'posix.unistd' from file '/usr/local/bin/lua':
/usr/local/bin/lua:1: unexpected symbol near '<\127>'

### Log File

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the LuaLS VS Code extension behavior on Linux with the reported LUA_PATH and LUA_CPATH values, then compare the configured paths with the paths used by require for posix.unistd. Done means the extension or runtime uses the configured shared-library paths instead of searching only the workspace folder.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.