Hello everyone,
I’m trying to package an Open Runescape Classic launcher called OpenRSC. Unfortunately, I’m getting the following exception that doesn’t happen outside of Flatpak:
java.io.IOException: Cannot run program "java" (in directory "/home/wacket/.var/app/vet.rsc.OpenRSC.Launcher/extras/winrune/WinRune-master"): error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
at java.base/java.lang.Runtime.exec(Runtime.java:594)
at launcher.Utils.CmdRunner.run(CmdRunner.java:29)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
... 4 more
Looking at the source code, OpenRSC Launcher does the following steps:
- Downloads the game client
- Uses some CmdRunner (which takes a command and path to run the command on) to run
java -jar /home/wacket/.var/app/vet.rsc.OpenRSC.Launcher/extras/winrune/WinRune-master
inside the /home/wacket/.var/app/vet.rsc.OpenRSC.Launcher/extras/winrune/
directory
Based on the stacktrace, it seems CmdRunner can’t enter the /home/wacket/.var/app/vet.rsc.OpenRSC.Launcher/extras/winrune/
directory (although the directory exists on my system; I can cd
into it).
Does anyone have any ideas on what I can do to make this work? I’m new to using Flatpak as a dev so I could be overlooking something simple.
Some things I’ve tried -
- Granting full filesystem access
- Using subdirectories inside
.var/app/APP_ID/
, such as data
or cache
- Not using
.var/app/APP_ID
to store the client’s downloads, and using filesystem access to specific folders instead
As an aside, it seems to be able to download files into the directory and detect them no problem. It just can’t run java
from inside the directory
I have a copy of the Flatpak on my Github here if anyone wants to see specifics
Reading the stack more closely, it says Cannot run program java
… Perhaps it’s referring to not being able to find “java”, rather than not being able to find the directory.
As part of my finish-args, I have
"finish-args": [
"--share=network",
"--socket=x11",
"--device=dri",
"--socket=pulseaudio",
"--env=JAVA_HOME=/app/jre"
],
But perhaps that doesn’t necessarily mean it knows where java
is. Not sure if this is a lead yet, but posting per-emptively as I debug
Got it working! The answer was that it couldn’t find java
, not that it couldn’t find the directory.
Java installs by default to /app/jre/bin
, so you have to set env
in the finish args to include it:
"--env=PATH=/usr/bin:/app/bin:/app/jre/bin"
-
/usr/bin
is included since that’s where all the default exec things are, not sure if it’s needed but might as well
-
/app/bin
is where my build is going, so that needs to be in the path
-
/app/jre/bin
is where the java
bin lives, so you need that to run Java
You also no longer declare the JAVA_HOME env since you can just invoke java
now.
Hopefully this helps someone else too =)
Im getting the same error
I did exactly like yours but im still getting the same error
Here is my manifest
---
app-id: io.github.appoutlet.GameOutlet
runtime: org.freedesktop.Platform
runtime-version: '22.08'
sdk: org.freedesktop.Sdk
sdk-extensions:
- org.freedesktop.Sdk.Extension.openjdk17
command: gameoutlet
finish-args:
- --share=network
- --socket=x11
- --device=dri
- --env=PATH=/usr/bin:/app/bin:/app/jre/bin
modules:
- name: openjdk
buildsystem: simple
build-commands:
- /usr/lib/sdk/openjdk17/install.sh
- name: GameOutlet
buildsystem: simple
build-commands:
- ./gradlew packageReleaseUberJarForCurrentOS
- cp build/compose/jars/GameOutlet-*.jar /app/bin
sources:
- type: git
url: https://github.com/AppOutlet/GameOutlet.git
branch: main
Here is my output
messias@messias:~/Workspace/flathub$ flatpak-builder build-dir io.github.appoutlet.GameOutlet.yml --force-clean
Downloading sources
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /home/messias/Workspace/flathub/.flatpak-builder/git/https_github.com_AppOutlet_GameOutlet.git-X1ZU31/
Fetching git repo https://github.com/AppOutlet/GameOutlet.git, ref refs/heads/main
remote: Enumerating objects: 261, done.
remote: Counting objects: 100% (261/261), done.
remote: Compressing objects: 100% (227/227), done.
remote: Total 261 (delta 53), reused 130 (delta 19), pack-reused 0
Receiving objects: 100% (261/261), 440.99 KiB | 2.41 MiB/s, done.
Resolving deltas: 100% (53/53), done.
From https://github.com/AppOutlet/GameOutlet
* [new branch] main -> main
* [new tag] v1.0.1 -> v1.0.1
Initializing build dir
Committing stage init to cache
Starting build of io.github.appoutlet.GameOutlet
========================================================================
Building module openjdk in /home/messias/Workspace/flathub/.flatpak-builder/build/openjdk-1
========================================================================
Running: /usr/lib/sdk/openjdk17/install.sh
Committing stage build-openjdk to cache
========================================================================
Building module GameOutlet in /home/messias/Workspace/flathub/.flatpak-builder/build/GameOutlet-1
========================================================================
Switched to branch 'main'
Running: ./gradlew packageReleaseUberJarForCurrentOS
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
Error: module GameOutlet: Child process exited with code 1
Im on a Ubuntu 22.04