Skip to content

library_loader.py corrupts PATH on Unix/Linux by using semicolons instead of colons #118

Description

@YusDyr

Bug Description

library_loader.py unconditionally uses semicolons (;) as PATH separator when appending directories to os.environ["PATH"] (lines 104-105 and 120-121):

os.environ["PATH"] += ";" + ";".join((os.getcwd(), _here))
if paths: os.environ["PATH"] += ";" + ";".join(paths)

This is the Windows PATH separator. On Unix/Linux/macOS, the PATH separator is a colon (:). This corrupts the PATH for the entire process and all child processes spawned afterward.

Impact

Any application that imports PyOgg on a non-Windows platform will have its PATH silently corrupted. Commands located in directories after the first semicolon become unreachable. In my case, this caused /bin/date, /bin/ln, /bin/stat to become unavailable in child shell processes, while /usr/bin/ffmpeg (appearing before the corruption point) still worked — a very confusing failure mode.

Environment

  • Python 3.14
  • Linux (Docker, Alpine-based)
  • PyOgg installed as a dependency of another package

Expected Behavior

The separator should be os.pathsep (which is : on Unix, ; on Windows), or the PATH modification should be guarded to only run on Windows where it's actually needed.

Suggested Fix

os.environ["PATH"] += os.pathsep + os.pathsep.join((os.getcwd(), _here))
if paths: os.environ["PATH"] += os.pathsep + os.pathsep.join(paths)

I'll submit a PR with this fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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