Skip to content

star installs extensions where it does not search: any prefix but ~/.local or /usr/local is invisible #989

Closed

Description

@David-Noble-at-work

Corrected 2026-09-30, after reading the design this should have started from.

docs/architecture/9-star-extensions.md defines four scopes — project, user, system, embedded — and says which
tool writes each. Defect 1 below proposed a fifth path, derived from the running binary, to find what
star self install writes to $PREFIX/share/devlore/star/extensions.

That path serves no scope. self install should write no extensions at all: builtin extensions are embedded
and travel in the binary, and every other extension is placed deliberately — by writ at user scope, or by the
repository at project scope. The prefix payload it was searching for is itself the defect, now
#990.

The probe was implemented, committed, and then reverted. It accommodated a breach instead of reading the design
that forbids it. Defect 1 is withdrawn. Defects 2, 3 and 4 stand and are fixed; all three are sanctioned by
the design.


star installs its extensions to $PREFIX/share/devlore/star/extensions and searches a list that was
written independently of that. The two agree for exactly two prefixes, by coincidence, and for any other
prefix make install reports success while star never sees the extensions.

The search list today

cmd/star/extension/loader.go:233, defaultSearchPaths():

# Path Source label it gets
0 config.GitWorkspaceRoot() + /star/extensions SourceProjectLocal
1 devlore.DataPath("star", "extensions") = ${XDG_DATA_HOME}/devlore/star/extensions SourceUser
2 xdg.DataPath("star", "extensions") = ${XDG_DATA_HOME}/star/extensions — deprecated, #920 SourceSystem
3 /usr/local/share/devlore/star/extensions — string literal SourceSystem
4 /usr/local/share/star/extensions — deprecated, #920 SourceSystem
5 the embedded FS SourceEmbedded

The installer writes to $PREFIX/share/devlore/star/extensions — cmd/star/star/root.go:329,
prefixRoot.NewPath("share", "devlore", "star", "extensions"), where the prefix is self install's
argument and make install passes PREFIX, default ~/.local.

Four defects

1. Any prefix other than ~/.local or /usr/local installs somewhere nothing searches

PREFIX Installed to Searched
~/.local ~/.local/share/devlore/star/extensions yes, by row 1 — only because XDG_DATA_HOME is unset
/usr/local /usr/local/share/devlore/star/extensions yes, by the literal in row 3
/opt/devlore, ~/apps, a container prefix $PREFIX/share/devlore/star/extensions no

Silent: the install succeeds and the extensions are simply absent.

There is no exe-relative search path, which is what would make the search follow the prefix. The logic
already exists in this repository, on the installer side: root.go:382 computes
filepath.Join(filepath.Dir(filepath.Dir(exe)), "share") to find extensions in an unpacked release
archive. The loader does not have it.

2. The installer resolves its source relative to the working directory, not the repository root

root.go:374, findExtensionsDir():

if info, err := os.Stat(filepath.Join("star", "extensions")); err == nil && info.IsDir() {
    return filepath.Join("star", "extensions")
}

That is ./star/extensions — found only when self install runs from the repository root. The loader does
the same job correctly one file away, with config.GitWorkspaceRoot() (loader.go:236). Same concept, two
implementations, one wrong.

3. /usr/local/share is a string literal, and xdg.DataDirs() is unused

pkg/xdg/xdg.go:142 already implements the specification's answer:

func DataDirs() []string { return dirs(envDataDirs, "/usr/local/share", "/usr/share") }

Nothing in the codebase calls it. The loader hardcodes one of its two defaults, so /usr/share is never
searched and XDG_DATA_DIRS is ignored. The user half of the spec is honored (XDG_DATA_HOME, via
DataHome) and the system half is not.

4. Source labels are assigned by index, and the array is shorter than the list

loader.go:79:

sources := []Source{SourceProjectLocal, SourceUser, SourceSystem}
for i, dir := range l.searchPaths {
    source := SourceSystem
    if i < len(sources) {
        source = sources[i]
    }

Row 2 is ${XDG_DATA_HOME}/star/extensions, a user path, reported as system. It does not change
resolution order, only what narration and diagnostics say about where an extension came from — which is
what someone reads when an extension resolved from somewhere they did not expect.

What it should be

Prior art converges: derive from the binary, then let the environment override.

  • Git finds git-core relative to the runtime binary; git --exec-path exposes it.
  • Python computes sys.prefix from the executable, which is what makes an install relocatable.
  • Go derives GOROOT from the executable path when unset.
  • Clang finds its resource directory relative to the driver.
  • The XDG specification is XDG_DATA_HOME, then XDG_DATA_DIRS — the directly applicable standard,
    already half-implemented here, with xdg.DataDirs() sitting unused.

So: repository root, then exe-relative (<dir of star>/../share/devlore/star/extensions), then
XDG_DATA_HOME, then XDG_DATA_DIRS, then embedded — with both /usr/local literals gone, since
DataDirs() already defaults to them.

Done when

Plan and design documents

Kind Document
Plan docs/plans/fix/964-ci-lints-neither-markdown.md

Found 2026-09-30 while tracing why a template edit produced no regenerated output: the deployed copy of
com.noblefactor.devlore.Actions was three days stale, which raised the question of when the deployed copy
is consulted at all.

related: #918 (where the
devlore/ move was made), #920 (which drops rows 2
and 4)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions