Skip to content

fix(startup): scope generated-content and upload dirs to the current user#10698

Merged
mudler merged 1 commit into
masterfrom
fix/per-user-generated-content-paths
Jul 6, 2026
Merged

fix(startup): scope generated-content and upload dirs to the current user#10698
mudler merged 1 commit into
masterfrom
fix/per-user-generated-content-paths

Conversation

@localai-bot

Copy link
Copy Markdown
Collaborator

What

Scope the default --generated-content-path and --upload-path to the current user so LocalAI no longer fails to start on multi-user hosts.

Why

The defaults were the fixed, shared locations /tmp/generated/content and /tmp/localai/upload. On any machine with more than one account these collide:

  • macOS routes /tmp to the shared /private/tmp for every user. Whichever account starts LocalAI first creates the parent directory with 0750 perms, and every other account then fails startup with:

    ERROR Error running the application  error=LocalAI failed to start: unable to create ImageDir: "mkdir /tmp/generated/content: permission denied".
    ERROR Error running the application  error=LocalAI failed to start: 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 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 run with no path flags.

How

  • Server defaults (root cause): both paths now default under the OS temp dir via os.TempDir() (honoring POSIX $TMPDIR, and already per-user on macOS) namespaced by the current UID: TMPDIR/localai-<uid>/generated/content and TMPDIR/localai-<uid>/upload. Wired through new kong vars in cmd/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 from GeneratedContentDir, so they are fixed transitively.
  • Launcher (defense in depth): the desktop launcher now anchors these two paths under its own per-user data directory too, mirroring the Launcher does not pass --data-path, --config-dir, or --state-dir to local-ai run, causing state dirs to resolve to ~/data and ~/configuration instead of under ~/.localai #10610 fix for data/configuration. The local-ai run arg assembly was extracted into a testable BuildRunArgs.
  • Docs: updated cli-reference.md.

Overrides are unchanged: LOCALAI_GENERATED_CONTENT_PATH / --generated-content-path (and the upload equivalents) still take precedence, and TMPDIR=/somewhere relocates the whole tree.

Verification

$ local-ai run --help | grep -E 'generated-content-path|upload-path'
  --generated-content-path="/tmp/localai-1000/generated/content"
  --upload-path="/tmp/localai-1000/upload"

$ TMPDIR=/blah local-ai run --help | grep -E 'generated-content-path|upload-path'
  --generated-content-path="/blah/localai-1000/generated/content"
  --upload-path="/blah/localai-1000/upload"

New unit tests: core/cli/run_paths_test.go (server defaults are user-scoped, not the historical shared paths) and a BuildRunArgs spec in cmd/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]

…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 mudler merged commit 461ae84 into master Jul 6, 2026
60 checks passed
@mudler mudler deleted the fix/per-user-generated-content-paths branch July 6, 2026 10:53
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.

2 participants