fix(startup): scope generated-content and upload dirs to the current user#10698
Merged
Conversation
…user
The `--generated-content-path` and `--upload-path` defaults were the fixed
shared locations `/tmp/generated/content` and `/tmp/localai/upload`. On any
multi-user host these collide across accounts: macOS routes `/tmp` to the
shared `/private/tmp` for every user, so whichever account starts LocalAI
first creates the parent with 0750 perms and every other account then fails
startup with:
unable to create ImageDir: "mkdir /tmp/generated/content: permission denied"
unable to create UploadDir: "mkdir /tmp/localai/upload: permission denied"
The same happens on Linux once a stale root-owned `/tmp/generated` (e.g. from
a prior `sudo` run) is left behind. This bites the desktop launcher and any
app embedding the raw binary (Wingman, nib-desktop), which start `local-ai
run` with no path flags.
Default both paths under the OS temp dir (`os.TempDir()`, honoring `$TMPDIR`;
already per-user on macOS) namespaced by the current UID
(`TMPDIR/localai-<uid>/...`), so accounts never collide while the paths stay
ephemeral. Wired via new kong vars in main.go so every consumer of the raw
binary inherits the fix. All content subdirs (audio, images) derive from
`GeneratedContentDir`, so they are fixed transitively.
As defense in depth, the launcher also anchors these two paths under its own
per-user data directory (mirroring the #10610 fix for data/config), extracted
into a testable `BuildRunArgs`.
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude:claude-opus-4-8 [Claude Code]
mudler
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Scope the default
--generated-content-pathand--upload-pathto the current user so LocalAI no longer fails to start on multi-user hosts.Why
The defaults were the fixed, shared locations
/tmp/generated/contentand/tmp/localai/upload. On any machine with more than one account these collide:macOS routes
/tmpto the shared/private/tmpfor every user. Whichever account starts LocalAI first creates the parent directory with0750perms, and every other account then fails startup with:The same happens on Linux once a stale root-owned
/tmp/generated(e.g. from a priorsudorun) is left behind.This was observed on macOS both with the desktop launcher and with the raw binary invoked directly by apps that embed LocalAI (Wingman, nib-desktop), which start
local-ai runwith no path flags.How
os.TempDir()(honoring POSIX$TMPDIR, and already per-user on macOS) namespaced by the current UID:TMPDIR/localai-<uid>/generated/contentandTMPDIR/localai-<uid>/upload. Wired through new kong vars incmd/local-ai/main.go(cli.DefaultGeneratedContentPath/cli.DefaultUploadPath) so every consumer of the raw binary inherits the fix. The paths stay ephemeral; all content subdirs (audio, images, …) derive fromGeneratedContentDir, so they are fixed transitively.data/configuration. Thelocal-ai runarg assembly was extracted into a testableBuildRunArgs.cli-reference.md.Overrides are unchanged:
LOCALAI_GENERATED_CONTENT_PATH/--generated-content-path(and the upload equivalents) still take precedence, andTMPDIR=/somewhererelocates the whole tree.Verification
New unit tests:
core/cli/run_paths_test.go(server defaults are user-scoped, not the historical shared paths) and aBuildRunArgsspec incmd/launcher/internal/launcher_test.go(launcher keeps generated-content/upload under its data dir, never/tmp).Assisted-by: Claude:claude-opus-4-8 [Claude Code]