Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: luarocks, luaflock, lua-sql-sqlite3 #766

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

cldellow
Copy link
Contributor

@cldellow cldellow commented Oct 4, 2024

This updates the Docker container to have some useful packages that a user might want available to their Lua scripts:

  • luaflock: BSD-style flock
  • lua-sql-sqlite3: SQLite bindings for Lua

It also updates tilemaker's Lua error handler to print the lua error code and error message string.

It seems like not all Lua errors have stack traces/tracebacks -- for example, requiring a non-existent module:

before this change:

lua runtime error:
terminate called after throwing an instance of 'OsmLuaProcessing::luaProcessingException'
  what():  std::exception

after this change:

lua runtime error 2:
./file_append.lua:7: module 'flock' not found:
	no field package.preload['flock']
	no file './flock.lua'
	no file '/usr/local/share/lua/5.1/flock.lua'
	no file '/usr/local/share/lua/5.1/flock/init.lua'
	no file '/usr/local/lib/lua/5.1/flock.lua'
	no file '/usr/local/lib/lua/5.1/flock/init.lua'
	no file '/usr/share/lua/5.1/flock.lua'
	no file '/usr/share/lua/5.1/flock/init.lua'
	no file './flock.so'
	no file '/usr/local/lib/lua/5.1/flock.so'
	no file '/usr/lib/x86_64-linux-gnu/lua/5.1/flock.so'
	no file '/usr/lib/lua/5.1/flock.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
terminate called after throwing an instance of 'OsmLuaProcessing::luaProcessingException'
  what():  std::exception

A drawback of this is that the case where there was already a useful error message is now quite spammy, e.g.:

lua runtime error 2:
/home/cldellow/src/basemap/export/city-parks.lua:27: attempt to perform arithmetic on global 'w' (a nil value)
table  `/home/cldellow/src/basemap/export/city-parks.lua:27: attempt to perform arithmetic on global 'w' (a nil value)'  `/home/cldellow/src/basemap/export/city-parks.lua:27: attempt to perform arithmetic on global 'w' (a nil value)'  
Lua error on node 21760675

...that's kind of unfortunate, but for me, is still a good tradeoff vs having nothing in some cases.

@systemed
Copy link
Owner

Thank you! This now has a conflict on the Dockerfile as a result of merging other PRs - I'm sure it's pretty straightforward but Docker is not really my thing so I'm a little anxious about breaking stuff; could you take a look?

@cldellow
Copy link
Contributor Author

Will do.

Some useful packages that a user might want available to their
Lua scripts:

- `luaflock`: BSD-style flock
- `lua-sql-sqlite3`: SQLite bindings for Lua

Also print the lua error code and error message string in the error
handler. It seems like not all Lua errors have stack traces/tracebacks,
e.g. requiring a non-existent module:

before:

```
lua runtime error:
terminate called after throwing an instance of 'OsmLuaProcessing::luaProcessingException'
  what():  std::exception
```

after:

```
lua runtime error 2:
./file_append.lua:7: module 'flock' not found:
	no field package.preload['flock']
	no file './flock.lua'
	no file '/usr/local/share/lua/5.1/flock.lua'
	no file '/usr/local/share/lua/5.1/flock/init.lua'
	no file '/usr/local/lib/lua/5.1/flock.lua'
	no file '/usr/local/lib/lua/5.1/flock/init.lua'
	no file '/usr/share/lua/5.1/flock.lua'
	no file '/usr/share/lua/5.1/flock/init.lua'
	no file './flock.so'
	no file '/usr/local/lib/lua/5.1/flock.so'
	no file '/usr/lib/x86_64-linux-gnu/lua/5.1/flock.so'
	no file '/usr/lib/lua/5.1/flock.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
terminate called after throwing an instance of 'OsmLuaProcessing::luaProcessingException'
  what():  std::exception
```
@cldellow cldellow force-pushed the docker-and-lua-errors branch from 818226f to 40f366f Compare October 17, 2024 15:00
@cldellow
Copy link
Contributor Author

This should be good now.

@systemed systemed merged commit 7c838e0 into systemed:master Oct 18, 2024
7 checks passed
@systemed
Copy link
Owner

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants