Skip to content

**Title:** Bug: PATH environment variable overwritten during script execution, breaking standard OS commands #69

@Adithyakp86

Description

@Adithyakp86

Title: Bug: PATH environment variable overwritten during script execution, breaking standard OS commands

Bug Description

When executing a user-defined script (e.g., ppm run my_script), ppmm overwrites the PATH environment variable for the child process instead of prepending the virtual environment path to it.

Because the existing system PATH is destroyed, standard OS commands like git, make, echo, or gcc become unavailable and fail to execute if they are included in a script within project.toml.

Location

  • src/project_managers.rs inside RunScript::run_script (line 399) and BuildProject::build_project (line 642).

Technical Details

Currently, Command::env is used to completely replace the PATH environment variable for the child process:

cmd.env("PATH", get_venv_bin_dir(venv_root));


Proposed Solution
The script execution logic should retrieve the current PATH, and prepend the virtual environment's bin directory to it.

rust
let current_path = std::env::var("PATH").unwrap_or_default();
let separator = if cfg!(target_os = "windows") { ";" } else { ":" };
let new_path = format!("{}{}{}", get_venv_bin_dir(venv_root), separator, current_path);
cmd.env("PATH", new_path);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions