Skip to content

feat: Linux port - #12

Open
BenAuerDev wants to merge 44 commits into
serverpod:mainfrom
BenAuerDev:linux/port
Open

BenAuerDev wants to merge 44 commits into
serverpod:mainfrom
BenAuerDev:linux/port

Conversation

@BenAuerDev

@BenAuerDev BenAuerDev commented Nov 26, 2026 •

Copy link
Copy Markdown

Brings App Studio to Linux. The plan is in specs/linux_port.md; the AppImage's own parts (Add to Applications, in-app updates, the message on systems that cannot run it) are in specs/linux_appimage.md.

Four PRs, each merged into linux/port on my fork after I've tested it, so this is the one PR to review. The fifth (polish) follows as its own PR after this one.

  1. App runs: Linux app shell, platform basics, menus, quitting cleanly
  2. Setup works: Flutter + Serverpod CLI install, prerequisites
  3. Preview works: CEF fixes (shortcuts, broken auto-setup, own cache folder, frame buffer memory bug, clipboard on Wayland, no keyring prompt)
  4. Packaging: the AppImage, which adds itself to the app menu and updates itself (done); .deb and .rpm, see open question 1
  5. Polish: "Open in…" editors, notifications, uninstall

CI/release runs on your infra, so that stays with you; I deliver the build scripts and the in-app updater. make appimage builds the AppImage (tool/linux/build_appimage.sh), and tool/linux/appcast.sh signs one and adds it to an update feed. What your release workflows need for Linux is in a separate brief I sent along. CLAUDE.md now has a Linux section.

macOS and Windows behaviour stays unchanged; every Linux change is a Linux-only branch or file (one exception, a null check in the webview_cef plugin, see open question 4).

Tested on

System Machine Desktop What
Ubuntu 24.04.5 LTS, fresh install bare metal: Intel Iris Xe + NVIDIA RTX A500 GNOME: Wayland on the Intel GPU; X11, and Wayland with PRIME offload, on NVIDIA's driver 595 the whole first run on Intel, recorded below; preview and Hot Restart on the NVIDIA GPU in both sessions
Fedora 45, fresh install, SELinux enforcing bare metal, the same laptop KDE Plasma, Wayland the whole first run, recorded below: setup (no system packages needed), Add to Applications (KDE menu and icon), a new project, preview, Hot Restart, closing, a start from a terminal in the background
Ubuntu 26.04.1 LTS, fresh install VM (QEMU/KVM) GNOME, Wayland setup, projects, preview, Add to Applications, updates, and a test for each review fix
Arch (Omarchy) bare metal, my dev machine Hyprland, Wayland daily use while building: preview, typing, copy and paste, Hot Restart, closing
Debian 11, Alpine, Ubuntu 24.04 containers, no desktop – the message on systems that cannot run the AppImage

Not tested yet: an X11 session on an Intel GPU.

Getting it running

  • PR 1: App runs #1, plus #5 (no crash on quit, and a second close no longer cuts the teardown short)
  • PR 2: Setup works #2
  • PR 3: Preview works #3, plus #4 (no keyring prompt when the preview loads)
  • AppImage runs on Ubuntu #6: setup installs Flutter + the Serverpod CLI, a new project opens, the server runs, the preview works, Hot Restart and menus work, closing stops the server. Added to the app menu with Gear Lever, it shows App Studio's own icon in the dock.
  • Same on Arch: setup found Flutter and the CLI already installed instead of installing them
  • Same on Fedora 45 with KDE Plasma and SELinux enforcing, with no SELinux denials

Polish

  • The AppImage adds itself to the app menu and updates itself #7:
    • Without Gear Lever or AppImageLauncher, App Studio offers "Add to Applications" on start (moves it to ~/AppImages, app menu entry with icon), and Help has Add/Remove.
    • Help → Check for Updates and a daily check work like Sparkle/WinSparkle: Sparkle appcast, Ed25519 signature, https only; the AppImage is replaced in place and restarts. Off until linux/release.json names your feed and key.
    • On a system that cannot run it (Ubuntu 22.04, no glibc, missing libraries), double-clicking now says why instead of doing nothing.
  • Fixes from a full review of the port #8: eight reviewers, each with its own focus, every finding verified; the eleven that mattered are fixed (among them a feed version that could have added lines to the menu entry, and the update offer opening over New Project). Each fix tested in the VM.
  • Start from a terminal, and say when Add copies #9: a background start (&) no longer freezes App Studio, and the Add question says when the AppImage is copied rather than moved.
  • PR 5: "Open in…" editors, notifications, uninstall, as a separate PR after this one

Not done yet: the release pipeline (yours), PR 5.

Known open points

Found in the review or in testing, not fixed yet:

  • Closing the preview: the plugin unrefs its texture right after unregistering it, while Flutter's raster thread may still be copying it. Not reproduced; a blind fix in native code seemed riskier than the bug.
  • Two App Studio copies updating at the same moment share one download file name.
  • The feed can offer any older signed build as a newer one, since the build number isn't signed. Sparkle has the same limit; https covers it.
  • Ctrl+F12 opens no DevTools on Linux.
  • The Linux-only tests don't run in CI, and the Makefile run targets and the MCP testing notes are macOS-only. Would you like an Ubuntu CI job?

Open questions

  1. .deb and .rpm: with the AppImage now updating itself, I'd skip them unless someone asks. Fine with you?
  2. Updates: the feed URL, the signing key and the two workflow jobs are yours; the brief has the details. Its feed URL (asdl.serverpod.dev/appcast/linux/…) only follows the macOS/Windows pattern; your call.
  3. Ubuntu baseline: 24.04 LTS or 26.04 LTS? The build needs glibc 2.38, so 24.04 and later work; 22.04 does not (it now says so). Both are tested (see above).
  4. macOS build: PR 3 touches packages/webview_cef/common/, all behind __linux__ or compiled to nothing elsewhere, except a null check in the Ctrl+F12 loop (Blue cloud-hero loading backdrop; open streams no longer hold the status spinner #8) that applies on every platform. I have no Mac and CI does not build macOS natively, so could one of you run a quick make build_debug and check the preview?
  5. Found on the way, not Linux-specific: a project named test fails in serverpod create, because the name collides with the template's test dependency. Neither the CLI nor App Studio's form refuses names of the template's dependencies, on any platform.

Recordings

The first run on Ubuntu 24.04 (bare metal), long waits sped up: download, system packages, Flutter and the Serverpod CLI, Add to Applications, an update from 0.4.1 to 0.4.2, the icon in the app menu, a new project, the app in the preview, a restart, closing.

app-studio-linux-ubuntu-24.04.mp4

The first run on Fedora 45 with KDE Plasma (bare metal), long waits sped up: setup without a system-packages step, Add to Applications, a new project, the app in the preview, Hot Restart, closing.

app-studio-linux-fedora-45-kde.mp4

BenAuerDev and others added 30 commits November 26, 2026 16:22
Plans App Studio on Linux as agreed with Serverpod: five PRs (app runs, setup works, preview works, packaging, polish), Tuesday as PRs 1–3 plus an AppImage running on Ubuntu and Arch, and CI, releases and auto-updates owned by Serverpod with build scripts delivered from here. Records what already works through the host seam, where Linux falls through to macOS behaviour, the CEF spike findings and the open questions.
The runner calls initCEFProcesses before GTK starts, so CEF's helper processes return instead of booting App Studio again, and hands the view's key events to the preview. The plugin's own script for this patches linux/main.cc, which current Flutter no longer generates. Window title App Studio, 1280x800, minimum 670x600 as on Windows.
App Studio's data goes in $XDG_DATA_HOME/dev.serverpod.appstudio, the folder shared_preferences already uses on Linux. The Windows menu strip is mounted on Linux too, with Quit on Ctrl+Q and no Uninstall until the uninstaller knows Linux. Inter for the UI and fontconfig's monospace, Ctrl in shortcut hints and in the terminal, xdg-open for links, and a linux-x64 platform key.
Only macOS builds ever shipped a private toolchain, so these tests already skipped on Windows; on a Linux host they failed.
feat: Linux PR 1, App Studio builds and starts on Linux
…o install them.

Linux's tool set is system packages, Flutter and the Serverpod CLI. git, curl, unzip and xz are probed on PATH; App Studio never runs sudo, so missing ones are a manual step: setup shows the apt, pacman, dnf or zypper command read from /etc/os-release, or the package names for a distro it does not know, with Check again, before anything else is installed.
… instructions put them.

Flutter comes from releases_linux.json and its .tar.xz is unpacked with tar. dart install puts the CLI in $XDG_STATE_HOME/Dart/install/bin. PATH lines go in the files Flutter's Linux instructions name: ~/.zshenv (or $ZDOTDIR/.zshenv), ~/.bashrc, or ~/.profile for sh and ksh. A Linux terminal starts a non-login shell, which reads neither of the macOS files.
feat: Linux PR 2, setup installs Flutter and the Serverpod CLI
On Linux CEF runs its own message loop thread, so script results and page events arrived there, while Flutter's Linux embedder only takes method channel responses and calls on the main thread. From CEF's thread they were lost: evaluateJavascript never answered and the preview waited on "Waking Flutter" forever. Responses and events now hop to the main thread with g_main_context_invoke_full, as Windows does with PostMessage. The encoded response is also released after use; it leaked before.
… thread.

CEF paints on its own thread on Linux while Flutter reads frames on its render thread and the app closes previews on GTK's. The texture freed each frame with delete instead of delete[] and swapped the buffer while the render thread could still read it; it now copies each frame under a GMutex into a buffer only the render thread touches, and hands Flutter a transparent pixel until the first frame arrives. The renderer map in common/webview_plugin.cc is guarded by a Linux-only lock, and a paint holds its own reference to the renderer, so a close can no longer free a texture mid-frame. A renderer's last reference may now go on CEF's thread, so its texture is unregistered and freed on GTK's. The texture used to leak; it is freed now. macOS and Windows keep their behaviour: the lock compiles to nothing there.
…gure time.

target_modifier/modify_target.sh patched linux/main.cc and linux/my_application.cc, which current Flutter no longer generates: they live in linux/runner/. It patched nothing, printed a warning on every configure, and left every CEF helper booting a full copy of the app. App Studio wires initCEFProcesses and the key handlers into its runner by hand since PR 1, so the plugin's CMake no longer runs the script.
…n Linux.

Without a root_cache_path CEF used ~/.config/cef_user_data, one folder and one singleton lock for every CEF app on the machine that also left it unset, so a killed run could block the next start. This is the bug the macOS and Windows ports already fixed. The Linux plugin now exports setCEFRootCachePath, and the runner sets it to $XDG_DATA_HOME/dev.serverpod.appstudio/CEF before CEF starts, inside the data folder App Studio already uses (L5), so uninstall removes it with the rest. A path that is not valid UTF-8 logs a warning and leaves CEF's default.
…focus.

With a page focused the plugin sent every key to CEF and reported it handled, so Flutter never saw Ctrl+R, Ctrl+L or any other app shortcut. Ctrl on a character key now goes to App Studio, except Ctrl+A/C/V/X/Y/Z, which stay the page's editing keys, as do Ctrl+Backspace, Ctrl+Enter and the other non-character keys. Keys are classified by their Windows key code, as Chromium does, so this holds on layouts without Latin letters. Modifiers go to both, a shortcut's release follows its press, and keys Flutter puts back unhandled are recognised and not sent to the page a second time. A modifier's own press now carries its own flag: GDK reports the state from before the event, and Flutter web asserted on a Ctrl press without Ctrl down. The xclip paste workaround is gone: it failed silently and xclip is not installed by default.
…gh GTK.

On Wayland a client may only set or read the clipboard while one of its surfaces has keyboard focus. CEF talks to the compositor over its own connection and draws off-screen, so it never has focus: copies stayed inside the page ("No serial found for selection" in CEF's log), and text copied elsewhere never arrived. GTK's window has the focus, so the plugin moves the text across. On Ctrl+C or Ctrl+X it puts the page's selection, which CEF reports through OnTextSelectionChanged, on the clipboard; on Ctrl+V or Shift+Insert it reads the clipboard and inserts the text the way an input method commits it. The page sees typing rather than a paste event, which is what a text field needs; a page that reads paste events, such as one pasting images, gets nothing. Running CEF on X11 through XWayland was tried first: Hyprland does not pass an unfocused X client's clipboard across.
Chromium keeps the key that encrypts cookies and saved passwords in the desktop's keyring. On a desktop without an unlocked one, such as a fresh Ubuntu 26.04 or one with automatic login, GNOME asked the user to create a "Default keyring" as soon as the preview loaded. CEF now gets password-store=basic on Linux, as macOS already gets use-mock-keychain: the preview shows a local development app and stores nothing that needs the keyring.
Linux PR 3b: no keyring prompt from the preview
Flutter's quit on Linux (quit_application in fl_platform_handler.cc) stops the main loop but leaves the window, and the engine inside, alive: nothing shuts the engine down, and its raster thread may still be drawing the preview's last frame. exit() then ran Mesa's teardown underneath it, and App Studio crashed on quit after its own teardown had already stopped the server. Flutter only quits once Dart has answered the exit request, so that teardown is done by the time the main loop returns: main() now flushes stdio and ends the process with _exit. Measured by opening a project and closing the window the way the close button does: 2 crashes in 8 quits before, none in 12 after.
…Linux.

Dart answered every exit request after the first with "exit" at once, so on Linux a second one during the teardown quit App Studio before the server was stopped: the close button twice, or File → Quit (Ctrl+Q) and then the close button, which reach Dart by different routes. A repeat request on Linux now waits for the running teardown, at most 15 s, since the CEF quit inside it has no timeout of its own and a hung teardown must not make the app impossible to close. macOS and Windows keep answering a repeat at once; Windows already drops a second close in window_close.dart.
Linux PR 1b: quit without crashing, and without cutting the teardown short
tool/linux/build_appimage.sh makes a release build and packs it into dist/linux/AppStudio-<version>-x86_64.AppImage; make appimage runs it. The bundle keeps its layout under usr/lib/appstudio, so the executable finds its libraries through its RPATH and CEF's helpers start from inside the mounted image. Libraries that still carry a symbol table are stripped, which takes libcef.so from 1.37 GB to 256 MB and the AppImage to 138 MB. The icons come from the Windows .ico, whose frames run edge to edge as Linux icons do. The desktop entry's StartupWMClass is the GTK application id, so docks match the window to it, and its X-AppImage-Version is the one version the AppImage carries: VERSION is unset for appimagetool, which would otherwise stamp whatever the caller's environment holds. The release build drops Widgetbook's url_launcher from the generated plugin files, so the script restores them, as build_release.ps1 does on Windows. Before packing, it checks the tools it needs, the bundle's files, and that the bundle was built from pubspec's version, so SKIP_BUILD cannot ship an old build under a new number. appimagetool and its runtime are pinned and checked against their sha256. With APPIMAGE_UPDATE_INFO set, the AppImage carries zsync update information for AppImageUpdate and Gear Lever, and a .zsync is written beside it; APPIMAGE_FILE_URL puts an absolute download URL in the .zsync, so each release can keep its own path. Hosting both is Serverpod's. Running it needs glibc 2.38 or newer (Ubuntu 24.04 and later).
Launcher search matches the start of each word of a desktop entry's Name, so "app" and "studio" found App Studio but "appstudio" found nothing (seen in GNOME on Ubuntu). The desktop entry now carries Keywords for its one-word name and for Serverpod, Flutter and Dart.
Linux PR 4: an AppImage, built with make appimage
… it.

On a system that cannot load App Studio, with a glibc or C++ runtime too old or a system library such as GTK missing, the executable failed before any of App Studio ran, so a double-click did nothing visible and only a terminal showed the loader's error. AppRun now asks the loader first (LD_TRACE_LOADED_OBJECTS, which lists what the app needs without running it) and, when something is missing, says what: a newer Linux with glibc 2.38 or later and distributions that have it, no glibc at all, or the libraries to install. The message goes to the terminal and, when there is a display, to a window through zenity, kdialog or notify-send, falling through to the next tool when one cannot show it. The glibc version is read from the build, as the highest GLIBC_ version any ELF file in the bundle references, and a build that needs another version stops until the distributions the message names are updated. Tested with the packed AppImage on Debian 11 (glibc 2.31), Alpine (no glibc) and Ubuntu 24.04.
Without Gear Lever or AppImageLauncher, the AppImage never appears in the app menu and the dock shows a generic icon. The plan has App Studio offer to add itself on first start: it moves the file to ~/AppImages/AppStudio-x86_64.AppImage, copies its icons and writes a desktop entry with a marker, so Remove from Applications (and the uninstall in PR 5) takes away only what App Studio wrote. It asks only when no tool has added it yet. When someone starts a second copy, it offers to replace the copy in the app menu with a newer one, or to open the newer one instead of an older one. The spec also records the AppRun check that is already built, text for the download page, and that updates from inside the app come later.
Without Gear Lever, AppImageLauncher or appimaged, a downloaded AppImage
never appears in the app menu and the dock shows a generic icon. App
Studio now asks once it reaches the start page, as long as no desktop
entry names it. Add moves the file to ~/AppImages/AppStudio-x86_64.AppImage,
copies the icons and writes dev.serverpod.appstudio.desktop with an
X-AppStudio-AddedBy marker and the version it added.

Help gets Add to Applications or Remove from Applications, whichever
applies. Remove deletes only an entry carrying the marker and leaves the
file where it is.

Starting another copy while App Studio's own entry exists asks whether
to Replace it with a newer build, or offers to Open the newer one from an
older build. The same build says nothing. After a failed Replace the
entry no longer records a version, so a later download is never offered
in place of a newer copy.
macOS updates through Sparkle and Windows through WinSparkle; Linux had
no updater, so Check for Updates stayed greyed out. App Studio now does
the same job in Dart, with the same Sparkle appcast and the same rules:
Help -> Check for Updates, and a daily check (on by default, over the
start page only, so it never interrupts a running server).

An update downloads beside the AppImage, is checked against its length
and an Ed25519 signature, and is renamed over the running file. The
running copy stays mounted, quits through the usual teardown, and the
new file starts once it is gone. App Studio's menu entry records the
new version. Feeds and downloads must be https; plain http is accepted
only to this machine or a private address, for a local test feed.

The feed URL and public key live in linux/release.json, as on Windows,
and are empty until a feed exists: such a build reports updates as
unavailable. build_appimage.sh compiles them in, and
tool/linux/appcast.sh signs an AppImage and adds it to a feed.

Adds cryptography for the signature check and makes xml a direct
dependency.
BenAuerDev and others added 14 commits November 28, 2026 13:16
Add copies the icons into ~/.local/share/icons/hicolor/<size>/apps, but
GTK rescans a theme, and judges an icon cache stale, only when the
hicolor folder itself changes. When those folders were already there
(any app that puts icons there, or an earlier Remove), the app menu
showed a generic icon until the next login.

Add and Remove now add a file to the hicolor folder and take it away
again before rebuilding an icon cache, as xdg-icon-resource does. Remove
no longer creates the folder where there was none.
Linux PR 4b: the AppImage adds itself to the app menu and updates itself
…er lines.

The feed is not signed, only the file is, and its shortVersionString was
written into App Studio's desktop entry as it came. A version carrying a
line break (&serverpod#10; in the XML) would have added a line of its own, such as
an Exec= key, which the signature never covered.

An item whose version is not letters, digits, '.', '+' and '-' (64 at
most) is now left out of the feed, and every value written to the entry
has its line breaks, tabs and carriage returns escaped as the Desktop
Entry spec says.
The hourly update check only asked whether a project was open, so once a
check was due its offer could open over the New Project screen or the
Settings dialog, both routes over the start page. Its Install button quits
App Studio, which would have left serverpod create or a tool install
half-done.

The start page now counts as showing only when nothing is pushed over it.
The Add to Applications question reads the same check.
Cancel was only read when the next chunk arrived. With a server that had
stopped sending, the dialog waited out the 60 s timeout and then reported
"The download stopped answering." instead of going back.

UpdateCancellation now completes a future when it is cancelled, and the
download stops waiting on the connection or the next chunk as soon as it
does. One listener serves the whole download. A response that arrives
after Cancel has its body let go, so its connection does not stay open.

The new tests stall the server, once while connecting and once
mid-download, and fail on the old code.
When Add to Applications cannot take the AppImage out of its folder (a
root-owned one such as /opt), it copies it to ~/AppImages and leaves the
original. The updater still preferred $APPIMAGE because the original
existed, so the download failed in a folder it cannot write to.

The updater now replaces the app menu's copy whenever App Studio's entry
names it and records the running build, and the started file otherwise.
A second copy of the same build, run from ~/Downloads say, therefore
updates the menu's copy and restarts that one. A download an interrupted
run left behind is cleared beside both.
Closing a webview keeps its entry in m_renderers with a null renderer.
The Ctrl+F12 loop that opens DevTools dereferenced every entry, so the
shortcut crashed after any preview had been closed. It now skips null
entries, as getAnyBrowserFocused already does.
build_appimage.sh accepted a release config with only one of appcastUrl
and eddsaPublicKey, said "In-app updates off" and built an AppImage that
would never check for updates. It now refuses unless both or neither are
set.

appcast.sh only works on Linux (it runs the AppImage to read its version,
and uses GNU stat and base64), but on macOS it failed with an exec format
error. It now says so up front, and its header lists OpenSSL 3, python3
and GNU coreutils.
"There is nothing to add on another OS" passed no executable, so the
running file was not inside APPDIR and the status was unavailable even on
Linux. It now runs in the same AppImage environment as the Linux tests,
so only the OS check can make it unavailable.

The line break test for a recorded version now also reads the version
back, so it pins the escaping in both directions.
CLAUDE.md (AGENTS.md) gets a Linux section: the dev machine, where things
are, quitting and the _exit() it ends with, CEF, keys and the GTK
clipboard bridge, the AppImage, Add to Applications and in-app updates.
Its first line no longer calls App Studio a macOS IDE.

specs/linux_port.md keeps the plan agreed with Serverpod and says where
the build differs: the AppImage updates itself and .deb and .rpm follow
only if asked, how quitting was fixed, the clipboard and its limits, the
670x600 minimum, and the checklist ticked for what is done.

specs/linux_appimage.md marks parts A and B done and records the review
fixes: which copy an update replaces, why nothing in the feed is trusted
beyond the file's signature, no offer over New Project or Settings, and
Cancel.
Linux PR 4c: fixes from a full review of the port
Started from a terminal with `&`, App Studio froze before showing its
window. To find Flutter it runs the user's login shell as an interactive
shell, and an interactive bash opens the terminal it shares with App
Studio to set up job control. As a background job, the terminal answers
with SIGTTIN and stops the whole process group, App Studio included, so
not even the probe's own timeout fired: "Stopped (tty input)".

On Linux the shell now runs in a session of its own with no terminal
(ProcessStartMode.detachedWithStdio). Its output still comes back
through the pipes, and the kill after the answer still reaches it.
macOS keeps the normal start.
Started from a folder App Studio may not take the file out of (a
root-owned /opt, a read-only file system, or a shared sticky folder such
as /tmp holding someone else's file), Add copies the AppImage to
~/AppImages and the original stays. The question still said the file
moves.

The Add and Replace questions now say a copy goes to ~/AppImages and
the original stays. Whether that is the case is read from the folder's
permissions with test -w, -x and, for a sticky folder, -O, so nothing
is written there before the user answers.
Linux PR 4d: start from a terminal, and say when Add copies
@BenAuerDev
BenAuerDev marked this pull request as ready for review November 28, 2026 16:53

This branch has not been deployed

No deployments
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