LÖVE 11.1 AppImage and relative paths

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
grump
Party member
Posts: 436
Joined: Sat Jul 22, 2017 7:43 pm

LÖVE 11.1 AppImage and relative paths

Post by grump » Mon Apr 16, 2018 2:14 pm

I don't want to upgrade my system to 11.1 yet, so I tried the AppImage distribution. I quickly learned that this doesn't work:

Code: Select all

$ love-11.1-linux-x86_64.AppImage game.love

Code: Select all

Error: [string "boot.lua"]:481: Cannot load game at path '/tmp/.mount_AjgSUk/usr/game.love'
Make sure a folder exists at the specified path.
It only works when specifying the absolute path to the love file/game directory. This seems to be a common problem with AppImageKit. See also here.

This doesn't play well with my current build system. I can probably fix this with a shell script, but it would be nice if it worked out of the box and showed the same behavior as when using a vanilla installation. I don't know jack about AppImages, but the above links seem to suggest it can be fixed when building the image.

If there is another quick solution other than writing a script to expand the path, I'd love to know.


Edit: here's the solution I came up with (requires bash):

Code: Select all

#!/bin/bash
GAME="$(readlink -f ${@: -1})"
set -- "${@:1:$(($#-1))}"
love-11.1-linux-x86_64.AppImage $@ $GAME
I saved this as /usr/bin/love11, with the AppImage in the executable path. Makes both absolute and relative paths work.

User avatar
bartbes
Sex machine
Posts: 4943
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: LÖVE 11.1 AppImage and relative paths

Post by bartbes » Mon Apr 16, 2018 6:39 pm

Thanks for the links, it looks like AppImageKit sets the OWD environment variable to the working directory it was called in, I'll probably update the script to switch back to that directory.

grump
Party member
Posts: 436
Joined: Sat Jul 22, 2017 7:43 pm

Re: LÖVE 11.1 AppImage and relative paths

Post by grump » Sun Jun 03, 2018 12:33 pm

The script hack from above kind of works, but breaks when you use relative package paths. If anyone else is having this problem with the current AppImage, here's how to properly fix it:
  • Get the appimagetool AppImage for your system from here
  • Unpack the LÖVE AppImage:

    Code: Select all

    $ ./love-11.1-linux-x86_64.AppImage --appimage-extract
  • Replace squashfs-root/usr/bin/wrapper-love with this script. It's the fixed script from bartbes' repo:

    Code: Select all

    #!/bin/sh
    
    # For some reason this runs from the usr subdirectory
    APPIMAGE_DIR="${PWD}/.."
    cd "$OWD"
    exec "${APPIMAGE_DIR}/love" "$@"
  • Rebuild the AppImage:

    Code: Select all

    $ cd squashfs-root
    $ ~/appimagetool-x86_64.AppImage . /tmp/love-11.1-linux-x86_64.AppImage
You now have a LÖVE AppImage in /tmp that sets the correct working directory.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests