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

No documentation on how to use LuaRocks with rlua #290

Open
Lilith-In-Starlight opened this issue Jan 4, 2024 · 3 comments
Open

No documentation on how to use LuaRocks with rlua #290

Lilith-In-Starlight opened this issue Jan 4, 2024 · 3 comments

Comments

@Lilith-In-Starlight
Copy link

Lilith-In-Starlight commented Jan 4, 2024

EDIT: Previously titled "How to make HTTP requests with rlua?"

(Can't really find a more appropriate place to ask this question, if there's a better place, please point me to it!)

I'm trying out different crates that add scripting support, because I want to make a plugin system for my program that can add features without me having to expose them from the program (I want to keep the program minimal). The rlua crate is one of the ones I'm considering, but it seems like it lacks modules like http or socket in order to make requests.

This is one of the examples I could come up with of features that I don't see the point in adding to my program and then exposing for plugins to use if I'm never going to use that feature in the un-modded program.

Is there something I'm missing or is this outright impossible?

@jugglerchris
Copy link
Collaborator

Hi,
I guess the discussions might be a slightly better place than issues, but this is fine (and see below).

rlua wraps a stock Lua interpreter (https://www.lua.org/), so any Lua libraries should be available (for example https://luarocks.org/, which includes lua-http).

What's missing is documentation on using (for example) LuaRocks with rlua. I think it should be straightforward (especially when using one of the system-lua options) - I will treat this issue as a documentation bug.

Note that rlua by default disables loading non-pure-Lua libraries unless you call Lua::unsafe_new_with_flags and don't include the LOAD_WRAPPERS and REMOVE_LOADLIB flags.

@Lilith-In-Starlight
Copy link
Author

Oh my bad! I totally forgot github discussions were even a thing. I'll rename the issue more appropriately now that it's gonna be regarded as a documentation bug.

I'm using the builtin 5.4 lua option, because I don't want to make people have to install lua just to get the program to work. Since currently there is no documentation on it, how would I use LuaRocks with rlua?

@Lilith-In-Starlight Lilith-In-Starlight changed the title How can I make HTTP requests with rlua? No documentation on how to use LuaRocks with rlua Jan 5, 2024
@jugglerchris
Copy link
Collaborator

I've done some investigation and experimentation, and have a proof of concept using LuaRocks (and some notes) from an rlua executable: https://github.com/jugglerchris/rlua_luarocks

The example behaves enough like a lua binary to install its own copy of LuaRocks and use that (using builtin-lua54). That's not the only way - it would be possible to use a stock Lua install (with matching version) for LuaRocks, and point to the installed libraries from the application using rlua.

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

No branches or pull requests

2 participants