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

gopherlua doesn't support package.loadlib #126

Closed
Jan69 opened this issue Nov 15, 2022 · 3 comments
Closed

gopherlua doesn't support package.loadlib #126

Jan69 opened this issue Nov 15, 2022 · 3 comments
Assignees
Labels
documentation Related to the project documentation feature request Enhancement or feature request

Comments

@Jan69
Copy link

Jan69 commented Nov 15, 2022

for example, I would like to use Candran, which like Teal does some preproccessing, and results in vanilla lua (it's really cool, supports lua 5.4 features, and a lot of nice syntax shorthands, and preprocessor macros, yet can compile down to lua 5.1)...but algernon doesn't support native modules...
I set the package.path and package.cpath in code, i require() the module, that much works...but it has a dependendy, lpeglabel which is a native compiled .so file...(unlike normal lpeg which has LuLPeg and LPegLJ, I'm not aware of any pure-lua implementations of lpeglabel)
and if I try to normally include Candran, the way which works with normal lua, I get

ERRO[0000] Error in test.lua (interpreted as a server script):
/home/jan6/lua//lua_modules/share/lua/5.1/candran.lua:6158: module lpeglabel not found:
	no field package.preload['lpeglabel']
	stat /home/jan6/lua//lua_modules/share/lua/5.1/lpeglabel.lua: no such file or directory
	stat /home/jan6/lua//lua_modules/share/lua/5.1/lpeglabel/init.lua: no such file or directory
	stat ./lpeglabel.lua: no such file or directory
	stat /usr/local/share/lua/5.1/lpeglabel.lua: no such file or directory
	stat /usr/local/share/lua/5.1/lpeglabel/init.lua: no such file or directory, 
stack traceback:
	[G]: in function 'require'
	/home/jan6/lua//lua_modules/share/lua/5.1/candran.lua:6158: in function '_'
	/home/jan6/lua//lua_modules/share/lua/5.1/candran.lua:7014: in function </home/jan6/lua//lua_modules/share/lua/5.1/candran.lua:0>
	[G]: in function 'require'
	test.lua:21: in main chunk
	[G]: ? 

so it seems to only be looking for .lua file, instead of .so

apparently gopherlua doesn't support package.loadlib but algernon doesn't mention that, and it's annoying having to go on a hunt for whether any given part of the program itself, doesn't support something, or if it's just the program being buggy

I assume it would be possible to instead have a Plugin that runs it through another lua interpreter...but that seems quite annoying workaround, and assumes the host has it's own lua available...

or alternatively, would be required to manually compile candran code and send to the server, instead of being able to have the whole source be included in the .alg, which also sucks...

@xyproto
Copy link
Owner

xyproto commented Nov 15, 2022

Thanks for reporting!

@xyproto
Copy link
Owner

xyproto commented Nov 15, 2022

I was not aware of the possibility to include native code for other Lua interpreters. For now, I'll add a note to the documentation, but contributions to make package.loadlib work would also be warmly welcome.

@xyproto xyproto added the documentation Related to the project documentation label Nov 15, 2022
@xyproto xyproto self-assigned this Nov 15, 2022
@xyproto xyproto changed the title native modules don't work, and *aren't mentioned not working* gopherlua doesn't support package.loadlib Apr 24, 2023
@xyproto xyproto added the feature request Enhancement or feature request label Apr 24, 2023
@tooolbox
Copy link
Collaborator

I'm curious what other Lua VM implementations support LoadLib, and in particular which ones written in Go that support LoadLib. Perhaps one that's just a wrapper around the C implementation, but then you're using cgo.

  • Shopify's doesn't seem to support it.
  • This one doesn't.
  • What else is there?

Do Lua interpreters written in other languages support native modules?

xyproto added a commit that referenced this issue May 17, 2023
@xyproto xyproto closed this as completed May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Related to the project documentation feature request Enhancement or feature request
Projects
None yet
Development

No branches or pull requests

3 participants