uspgamedev / luasteam

Bindings to connect lua with Steam API
https://luasteam.readthedocs.io/en/stable/
MIT License
116 stars 19 forks source link

Installation instructions wrong for OSX #22

Open globalcitizen opened 3 years ago

globalcitizen commented 3 years ago

Environment

Issue

When downloading this codebase and following the luasteam instructions....

Download the correct binary for your platform and rename it to simply luasteam.ext.

... and renaming to luasteam.ext, the library is not found:

Error

engine/external/init.lua:7: module 'luasteam' not found:
no field package.preload['luasteam']
no 'luasteam' in LOVE game directories.
no file 'luasteam' in LOVE paths.
no file './luasteam.lua'
no file '/usr/local/share/luajit-2.0.5/luasteam.lua'
no file '/usr/local/share/lua/5.1/luasteam.lua'
no file '/usr/local/share/lua/5.1/luasteam/init.lua'
no file './luasteam.so'
no file '/usr/local/lib/lua/5.1/luasteam.so'
no file '/usr/local/lib/lua/5.1/loadall.so'

Traceback

[C]: in function 'require'
engine/external/init.lua:7: in main chunk
[C]: in function 'require'
engine/init.lua:5: in main chunk
[C]: in function 'require'
main.lua:1: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'

This appears to be verified by third parties as per the comments in issue #14.

Attempted resolutions

Renaming to luastream.so

Renaming to luasteam.so appears to work better (also as per those comments), however still yields the error:

Error

error loading module 'luasteam' from file './luasteam.so':
dlopen(./luasteam.so, 6): no suitable image found.  Did find:
file system relative paths not allowed in hardened programs

Traceback

[C]: at 0x010927c740
[C]: in function 'require'
engine/external/init.lua:7: in main chunk
[C]: in function 'require'
engine/init.lua:5: in main chunk
[C]: in function 'require'
main.lua:1: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'

Adding cpath hack to main.lua

As per this suggestion hack cpath.

local windows = package.config:sub(1, 1) == '\\'
package.cpath = string.format("%s;%s/?.%s", package.cpath, love.filesystem.getSourceBaseDirectory(), (windows and "dll" or "so"))

Didn't work, same error as above.

Situation

Can't use library following documentation's instructions on OSX. This is different to the other issue #14, which is about releasing on OSX.

yancouto commented 3 years ago

Well, this is weird.

I downloaded the code in my mac, and tried the simplest possible program

main.lua:

local steam = require "luasteam"

I tried running (love .) and got exactly the same error (file system relative paths not allowed in hardened programs). Notice that it first didn't let me use the .so (unsafe to open file) and I had to go in Security and Settings and Allow anyway so I didn't get this error anymore.

Then I tried to isolate the error: Ran also in my friends older mac, but it also didn't work, so it wasn't the Mac version.

Tried to rebuild the .so with latest sdk but still got the same issue.

Then I downloaded an older version of LOVE, 0.10.2, and it worked.

I was about to come back here saying that it is about LOVE version, but I kept testing with different versions and now even the latest version (11.3) works without error.

So I think it's some security thing inside Mac that eventually allowed me to use the .so and stopped complaining. No idea why it didn't just work after I "Allowed anyway", but still took a while after that. Sorry about the lack of a better answer.

That said, I believe when packaging the game this problem won't show up, because the .so goes inside the .app folder and Mac probably allows everything to run at once.

Also, the cpath hack is for packaging, so you can place the .so next to the .love file.

globalcitizen commented 3 years ago

So I think it's some security thing inside Mac

Yes, that is also my impression.

when packaging the game this problem won't show up

That's great but doesn't help with just using / potentially hacking on a codebase someone has shared, which was my intent.

In any event, the instructions don't work. Perhaps it would be a good idea to update them to prevent other people wasting time on this.