Skip to content

Enforce directory-only indexing, validate alias paths, and document pipx usage - #3

Merged
a584-droid merged 2 commits into
mainfrom
codex/fix-pip-install-e-installation-issue-omaxnc
Mar 12, 2026
Merged

Enforce directory-only indexing, validate alias paths, and document pipx usage#3
a584-droid merged 2 commits into
mainfrom
codex/fix-pip-install-e-installation-issue-omaxnc

Conversation

@a584-droid

Copy link
Copy Markdown
Owner

Motivation

  • Provide a way to export indexed entries as environment variables and manage a managed block in env files (/etc/environment).
  • Ensure the index only contains directories (not files) to avoid exporting non-directory paths.
  • Prevent adding aliases that point to non-existent or non-directory paths.
  • Document installation via pipx and show examples of exporting the index to env files.

Description

  • Restrict path discovery to directories by changing path_like to use Path.is_dir() and update collect_alias_entries accordingly.
  • Add CLI helpers normalize_env_name, is_env_name, and replace_managed_block, constants MANAGED_ENV_BEGIN/MANAGED_ENV_END, and the env sync command implemented in cmd_env_sync to export a managed block of env variables.
  • Add validation in cmd_alias_add to reject alias paths that are not existing directories and keep the existing alias storage behavior via save_aliases.
  • Update README.md with pipx installation instructions, examples for pathi env sync, and a note that only existing directories are indexed.

Testing

  • No automated tests were executed as part of this change.

Codex Task

@a584-droid a584-droid changed the title Add env sync export, enforce directory-only indexing, validate alias paths, and document pipx usage Enforce directory-only indexing, validate alias paths, and document pipx usage Mar 12, 2026
@a584-droid
a584-droid merged commit 59a4ccf into main Mar 12, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

lines.append(f'{key}="{out[key]}"')

P2 Badge Escape env values before emitting managed assignments

The managed block writes each variable as KEY="<path>" without escaping the path value, so any indexed directory containing " (or newlines) produces a malformed env assignment and can break parsing of the generated block. This is user-impacting in real files because POSIX paths can legally contain these characters; the exporter should escape or safely quote values before writing.


target = Path(args.file).expanduser()
existing = target.read_text(encoding="utf-8") if target.exists() else ""
updated = replace_managed_block(existing, block)
target.write_text(updated, encoding="utf-8")

P2 Badge Create destination parent directories before writing env file

When --print-only is not used, the command writes directly to args.file but never ensures target.parent exists, so paths like ~/.config/pathi/environment fail with FileNotFoundError on a fresh setup. This makes the new workflow brittle and aborts the sync instead of updating the managed block.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@a584-droid

Copy link
Copy Markdown
Owner Author

I doubt these changes. Probably should keep it that simple from first PR.

Only what needs to be investigated how to actually prevent paths to files.

After then might add more default paths like XDG_ ones or /home/user/.local/share/icons,~/.fonts etc.

@a584-droid
a584-droid deleted the codex/fix-pip-install-e-installation-issue-omaxnc branch March 13, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant