Skip to content

lua5_1, luajit and original luajit behave differently #189689

@jmoh932

Description

@jmoh932

Describe the bug

-- "tasting.lua"
print(string.gsub(package.path, ";", "\n").."\n")

Will behave differently on host luajit, nixpkg luajit and nixpkg lua5_1.

Expected behavior

  1. From LUA_PATH_DEFAULT of luaconf.h, there is not way lua runtime will automatically defaultly load something like ./myPkg/init.lua, but lua5_1 of nixpkg 22.05 will do this. I'm new to nix, can't see why?
  2. luajit and lua5_1 of nixpkg 22.05 behave differently. luajit will load all lua module from system path, lua5_1 will load all package from working directory. And both differently with my host luajit, which load module from both working directory and system path.
  3. Anyway, seems same patch both in lua5_1 and luajit, https://github.com/NixOS/nixpkgs/blob/22.05/pkgs/development/interpreters/luajit/default.nix#L62-L69, but luajit doesn't work expectly, so the default luajit from nixpkg 22.05 can't do anything as a standalone lua interpreter.

Screenshots

On macOS 12.5.1, LuaJIT 2.1.0-beta3

./?.lua
/usr/local/share/luajit-2.1.0-beta3/?.lua
/usr/local/share/lua/5.1/?.lua
/usr/local/share/lua/5.1/?/init.lua
/usr/local/share/lua/5.1/?.lua
/usr/local/share/lua/5.1/?/init.lua

On luajit of nixpkgs 22.05 with helping of shell.nix

/nix/store/db6sp8wgr97zn4qyyb7g42yhr00pqjiy-luajit-2.1.0-2022-04-05/share/lua/5.1/?.lua
/nix/store/db6sp8wgr97zn4qyyb7g42yhr00pqjiy-luajit-2.1.0-2022-04-05/share/lua/5.1/?/init.lua

On lua5_1 of nixpkgs 22.05 with helping of shell.nix

./share/lua/5.1/?.lua
./?.lua
./?/init.lua

Notify maintainers

@teto, 8884291

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
blabla...
blabla...
...
 - system: `"x86_64-darwin"`
 - host os: `Darwin 21.6.0, macOS 10.16`
 - multi-user?: `no`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.3.15`
 - channels(jack): `"nixpkgs-21.11pre306870.67c80531be6"`
 - nixpkgs: `/Users/jack/.nix-defexpr/channels/nixpkgs`

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: luaLua is a powerful, efficient, lightweight, embeddable scripting language.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions