Skip to content

Tools: Open the browser on Linux without stopping on an xdg-open error - #2386

Merged
dimensionscape merged 3 commits into
developfrom
fix/8.4.0-linux-open-browser
Nov 26, 2026
Merged

dimensionscape merged 3 commits into
developfrom
fix/8.4.0-linux-open-browser

Conversation

@dimensionscape

Copy link
Copy Markdown
Member

lime test html5 on Linux stops right after starting the test server with xdg-open: unexpected argument '&', so the page can't even be opened by hand. hxp 1.3.1's System.openURL() passes the URL and a literal & to xdg-open as two arguments, since it runs the command without a shell, and the failed command stops the tools. The bug has been in hxp for years; it surfaced now because http-server used to open the browser itself, and the CrossByte server calls openURL(). Projects with an app.url hit it on HTML5 and Flash in 8.3 already.

CommandHelper.openURL() runs xdg-open through the shell with the URL quoted, in the background, with its output discarded, and a failure no longer stops the tools. Windows and macOS still go through hxp. WebServer, HTML5Helper and FlashPlatform use it. The same fix for hxp is openfl/hxp#44; once Lime depends on an hxp release with it, this can go back to System.openURL().

The Tests commit adds OpenURLTest to the tools tests: a stand-in xdg-open first on the PATH records its arguments and takes 5 seconds to exit, and the test checks that the URL, with & and quotes in it, is the only argument and that openURL() returns without waiting. It runs in the Linux job and passes trivially on Windows and macOS. Locally (Windows) the tools tests pass and the tools compile; the shell command and the stand-in script were also run through sh with the same results the test expects. Not run on a Linux desktop with a real browser.

hxp 1.3.1's System.openURL() runs xdg-open with the URL and a literal "&" as two arguments, since it runs the command without a shell. xdg-open rejects the extra argument, and the failed command stops the tools. This went unnoticed while http-server opened the browser itself; the CrossByte server calls openURL(), so lime test html5 on Linux now stops before serving. Projects with an app.url hit it on HTML5 and Flash already.

The new CommandHelper.openURL() runs xdg-open through the shell, in the background, with the URL quoted for the shell and its output discarded. Windows and macOS still go through hxp. The web server, HTML5Helper and FlashPlatform use it.
…'s only argument

OpenURLTest puts a stand-in xdg-open first on the PATH, which records its arguments and takes 5 seconds to exit, and checks that CommandHelper.openURL() passes the URL, with & and quotes in it, as the only argument and returns without waiting. It runs in the tools tests of the Linux job and passes trivially elsewhere.
@dimensionscape dimensionscape added this to the 8.4.0 milestone Nov 24, 2026
…en-browser

# Conflicts:
#	src/lime/tools/CommandHelper.hx
@dimensionscape

Copy link
Copy Markdown
Member Author

Merged develop after #2389, which added CommandHelper.openURL() for Windows. The two are now one function: start with an empty title on Windows, hxp's openURL() on macOS, and xdg-open through the shell in the background on Linux. The Linux tests here still cover the Linux part.

@dimensionscape
dimensionscape merged commit 595593c into develop Nov 26, 2026
55 checks passed
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

Successfully merging this pull request may close these issues.

1 participant