Describe the bug
The LUA_PATH set by luajit's setup hook does not include the default value ?;?.lua (documented here), so relative imports from the current directory do not work.
To Reproduce
Create two files:
==> a.lua <==
print(require('b'))
==> b.lua <==
return "hi!"
~ $ nix-shell -p luajit
[nix-shell:~]$ which luajit
/nix/store/bafy33kb1drwgcdr031vhjl84ls0sni5-luajit-2.1.0-2020-12-28/bin/luajit
[nix-shell:~]$ echo $LUA_PATH
/nix/store/bafy33kb1drwgcdr031vhjl84ls0sni5-luajit-2.1.0-2020-12-28/lib/lua/5.1/?.lua;/nix/store/bafy33kb1drwgcdr031vhjl84ls0sni5-luajit-2.1.0-2020-12-28/share/lua/5.1/?.lua;/nix/store/bafy33kb1drwgcdr031vhjl84ls0sni5-luajit-2.1.0-2020-12-28/share/lua/5.1/?/init.lua;/nix/store/bafy33kb1drwgcdr031vhjl84ls0sni5-luajit-2.1.0-2020-12-28/lib/lua/5.1/?/init.lua
[nix-shell:~]$ luajit a.lua
luajit: a.lua:1: module 'b' not found:
no field package.preload['b']
no file '/nix/store/bafy33kb1drwgcdr031vhjl84ls0sni5-luajit-2.1.0-2020-12-28/lib/lua/5.1/b.lua'
no file '/nix/store/bafy33kb1drwgcdr031vhjl84ls0sni5-luajit-2.1.0-2020-12-28/share/lua/5.1/b.lua'
no file '/nix/store/bafy33kb1drwgcdr031vhjl84ls0sni5-luajit-2.1.0-2020-12-28/share/lua/5.1/b/init.lua'
no file '/nix/store/bafy33kb1drwgcdr031vhjl84ls0sni5-luajit-2.1.0-2020-12-28/lib/lua/5.1/b/init.lua'
no file '/nix/store/bafy33kb1drwgcdr031vhjl84ls0sni5-luajit-2.1.0-2020-12-28/lib/lua/5.1/b.so'
no file '/nix/store/bafy33kb1drwgcdr031vhjl84ls0sni5-luajit-2.1.0-2020-12-28/share/lua/5.1/b.so'
stack traceback:
[C]: in function 'require'
a.lua:1: in main chunk
[C]: at 0x004062c0
Expected behavior
From a non-nixos system (Arch):
~ $ which luajit
/usr/bin/luajit
~ $ echo $LUA_PATH
# unset
~ $ luajit a.lua
hi
Additional context
For some reason, nix-shell -p luajit sets a LUA_PATH but nix-shell -p lua does not. I don't really understand that.
Notify maintainers
@thoughtpolice @grwlf @vcunat @andir @lblasc
Metadata
- system:
"x86_64-linux"
- host os:
Linux 5.10.15-arch1-1, Arch Linux, noversion
- multi-user?:
yes
- sandbox:
yes
- version:
nix-env (Nix) 2.4pre20200721_ff314f1
- channels(root):
"nixpkgs-21.03pre246046.41c0f496810"
- channels(jamie):
""
- nixpkgs:
/home/jamie/Projects/nixpkgs (master)
Maintainer information:
# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
Describe the bug
The LUA_PATH set by luajit's setup hook does not include the default value
?;?.lua(documented here), so relative imports from the current directory do not work.To Reproduce
Create two files:
Expected behavior
From a non-nixos system (Arch):
Additional context
For some reason,
nix-shell -p luajitsets a LUA_PATH butnix-shell -p luadoes not. I don't really understand that.Notify maintainers
@thoughtpolice @grwlf @vcunat @andir @lblasc
Metadata
"x86_64-linux"Linux 5.10.15-arch1-1, Arch Linux, noversionyesyesnix-env (Nix) 2.4pre20200721_ff314f1"nixpkgs-21.03pre246046.41c0f496810"""/home/jamie/Projects/nixpkgs(master)Maintainer information: