Skip to content

[xpkg-report]: system.unix_api().append_to_shell_profile writes to the invoking directory, no PowerShell, no removal #55

Backlog

Description

@speak-agent

Context

Found while reviewing the mcpp shell-completion pull request in openxlings/xim-pkgindex, which needs to register shell integration from a hook and measured system.unix_api().append_to_shell_profile first.

Versions

libxpkg main (src/lua-stdlib/xim/libxpkg/system.lua), used by xlings 2026.11.23.1 (CI pin v2026.11.23.1), Linux x86_64.

Reproduce

Measured by the pull request's author with a probe xpkg; I confirmed the cause in the source, not by re-running it.

A probe recipe whose config() calls system.unix_api().append_to_shell_profile({ posix = "echo probe", fish = "echo probe" }), installed from a shell whose working directory contains copies named xlings-profile.sh / xlings-profile.fish (and with an isolated XLINGS_HOME whose config/shell/ holds the real ones).

Expected / actual

Expected: the profiles under <XLINGS_HOME>/config/shell/ get the line. Actual: the line is appended to the files in the directory xlings was invoked from; the real profiles stay byte-identical (and when the working directory has no such files the call silently does nothing).

Analysis

Observed (source): profile_dir = _RUNTIME.run_dir or "/tmp", and run_dir is the invoking process' working directory (make_execution_context: ctx.run_dir = current_path()), not the profile directory. Also: only posix and fish branches (no .ps1); append-only, with a plain-substring "already there" test, so a changed line accumulates and nothing can be removed on uninstall; no marker, so a package cannot own "its" part.
Suspected: the API predates the config/shell/ layout.
Suggested: target <XLINGS_HOME>/config/shell (or a profile.d/ drop-in, see the xlings issue linked below), add ps1, and offer an id-keyed add/remove so uninstall can undo it. Until then the index carries its own module (libs/shell_profile.lua in the mcpp pull request), which should migrate once this ships.

Filed by an AI agent while reviewing a contribution to xim-pkgindex.
Authorship: ai-and-human
Agent: Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions