Closed matklad closed 1 year ago
Hm, or maybe this doesn't work? After the local install ~/.luarocks/bin/djot -h
works for me, but ~/.luarocks/bin/djot example.djot
fails with
/nix/store/yp7zmdrj8lv3qsgq98h1q3lgvf2gsr2j-lua-5.2.4/bin/lua: /home/matklad/.luarocks/share/lua/5.2/djot/inline.lua:579: attempt to call upvalue 'unpack_match' (a nil value)
So, yeah, I wasn't able to get neithe global, nor local install to work for me. lua ./bin/main.lua
did the trick though!
luarocks --local make
works fine for me. But maybe the problem would reveal itself if I had your example.djot? Also, what version of lua are you running?
Here's some extra debug output:
[matklad@Ishmael:~/p/djot]$ lua -v
Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
[matklad@Ishmael:~/p/djot]$ luarocks --version
/nix/store/5da3vmaf17hvbcy27fdydf4lib0zifaa-luarocks-3.9.1/bin/.luarocks-wrapped 3.9.1
LuaRocks main command-line interface
[matklad@Ishmael:~/p/djot]$ echo $LUA_PATH
/nix/store/5da3vmaf17hvbcy27fdydf4lib0zifaa-luarocks-3.9.1/share/lua/5.2/?.lua;/nix/store/5da3vmaf17hvbcy27fdydf4lib0zifaa-luarocks-3.9.1/share/lua/5.2/?/init.lua;/home/matklad/.luarocks/share/lua/5.2/?.lua;/home/matklad/.luarocks/share/lua/5.2/?/init.lua
[matklad@Ishmael:~/p/djot]$ luarocks --local test
djot 0.1.0-1 depends on lua >= 5.1 (5.2-1 provided by VM)
djot 0.1.0-1 depends on luafilesystem >= 1.8 (1.8.0-1 installed)
Error running test task_lists.test line 13:
./djot/inline.lua:579: attempt to call upvalue 'unpack_match' (a nil value)
Error running test task_lists.test line 31:
./djot/inline.lua:579: attempt to call upvalue 'unpack_match' (a nil value)
Error running test definition-lists.test line 24:
./djot/inline.lua:579: attempt to call upvalue 'unpack_match' (a nil value)
Error running test definition-lists.test line 47:
./djot/inline.lua:579: attempt to call upvalue 'unpack_match' (a nil value)
Error running test definition-lists.test line 79:
Given that this is NixOS, it's highly likely that something's wrong on my end.
I think even local install from luarocks doesnt' work?
λ luarocks install --local djot
Installing https://luarocks.org/djot-0.1.0-1.src.rock
djot 0.1.0-1 depends on lua >= 5.1 (5.2-1 provided by VM)
No existing manifest. Attempting to rebuild...
djot 0.1.0-1 is now installed in /home/matklad/.luarocks (license: MIT)
15:27:30|~/p
λ ~/.luarocks/bin/djot -h
djot [opts] [file*]
Options:
-m Show matches.
-a Show AST.
-r Show references.
-p Include source positions in AST.
-M Show memory usage.
-v Verbose (show warnings).
-h Help.
15:27:46|~/p
λ ~/.luarocks/bin/djot /dev/null
/nix/store/yp7zmdrj8lv3qsgq98h1q3lgvf2gsr2j-lua-5.2.4/bin/lua: /home/matklad/.luarocks/share/lua/5.2/djot/match.lua:18: attempt to call field 'pack' (a nil value)
stack traceback:
/home/matklad/.luarocks/share/lua/5.2/djot/match.lua:18: in function 'make_match'
/home/matklad/.luarocks/share/lua/5.2/djot/block.lua:621: in function 'add_match'
/home/matklad/.luarocks/share/lua/5.2/djot/block.lua:738: in function 'parse'
...d/.luarocks/lib/luarocks/rocks-5.2/djot/0.1.0-1/bin/djot:75: in main chunk
[C]: in ?
(I also notice that CI wasn't kicking in here without your approval, it's possible to change this (or rather, revert to how it was a couple of years ago) if you want to https://matklad.github.io/2022/10/24/actions-permissions.html)
/nix/store/yp7zmdrj8lv3qsgq98h1q3lgvf2gsr2j-lua-5.2.4/bin/lua: /home/matklad/.luarocks/share/lua/5.2/djot/match.lua:18: attempt to call field 'pack' (a nil value)
This is hard to understand. If you look at match.lua, it should not be able to get to line 18 if string.pack is a nil value, because of the conditional on line 3.
However, I can reproduce the issue using nix-shell.
OK, I think I see the problem.
I think this commit fixes things (try luarocks install --local
again).
But I don't yet understand why it would work locally but not in luarocks.
Yup, that commit fixed luarocks test --local
for me:
λ luarocks test --local
djot 0.1.0-1 depends on lua >= 5.1 (5.2-1 provided by VM)
djot 0.1.0-1 depends on luafilesystem >= 1.8 (1.8.0-1 installed)
224 tests completed in 0.021 s
PASSED: 224
FAILED: 0
ERRORS: 0
The install still doesn't work though:
λ ~/.luarocks/bin/djot ./test/emoji.test
/nix/store/yp7zmdrj8lv3qsgq98h1q3lgvf2gsr2j-lua-5.2.4/bin/lua: /home/matklad/.luarocks/share/lua/5.2/djot/match.lua:18: attempt to call field 'pack' (a nil value)
stack traceback:
/home/matklad/.luarocks/share/lua/5.2/djot/match.lua:18: in function 'make_match'
/home/matklad/.luarocks/share/lua/5.2/djot/block.lua:621: in function 'add_match'
/home/matklad/.luarocks/share/lua/5.2/djot/block.lua:453: in function 'open'
/home/matklad/.luarocks/share/lua/5.2/djot/block.lua:700: in function 'parse'
...d/.luarocks/lib/luarocks/rocks-5.2/djot/0.1.0-1/bin/djot:75: in main chunk
[C]: in ?
Did you try it after the follow-up commit 55f2a12ddeaed46a8e8ed82e2e818d1141915661 ?
yup, that was as of 55f2a12ddeaed46a8e8ed82e2e818d1141915661
make install
wants to write to/
which isn't possible withoutsudo
(and, on something like NixOS, isn't possible at all). Luckily,luarocks
supports--local
flag for installing into~/.luarocks
. Add a make target for that.Note that I am not really comfortable with neither make nor lua, but that's the magic spell which worked for me on NixOS!