cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
4.12k stars 310 forks source link

Python doesn't have access to host PATHs in both pure and impure environments #1335

Open shahinism opened 2 months ago

shahinism commented 2 months ago

Objective: I am trying to invoke commands available in the host system's path using Python within a specific environment configuration.

Context: This issue is based on DataChefHQ/inception issue #21, where it was highlighted that Python cannot directly invoke commands available in the host system's path.

Problem: In my setup, as demonstrated in the image linked below, Python is unable to access system path commands.

Issue Demonstration

Configuration: Here is my current configuration:

{ pkgs, lib, config, inputs, ... }:

{
  env.GREET = "devenv";
  packages = [ ];
  languages.python.enable = true;
  scripts.hello.exec = "echo hello from $GREET";
}

Attempted Solutions: I learned that installing git inside the environment (adding to packages list) will resolve the issue. However, I am uncertain if this is the intended approach.

Request for Assistance: Please confirm if installing (or other similar tools) within the environment is the recommended solution for this issue. Additionally, if there are alternative methods or best practices to allow Python to invoke system path commands within this configuration, I would appreciate your guidance.

Side note: I think, in general, this is a suitable approach, enforcing developers to keep devenv's environment in sink with the code developed. However, observing the strange behavior where Python couldn't access it, but I could do it through CLI within the same environment, and the lack of documentation around it confused me and thought it's better to reach out.

kkiani commented 5 days ago

I am encountering a similar issue in a Linux environment using PDM. My project has a Python dependency that is fetched from a Git repository, which requires Git to be available. On macOS, everything works as expected. However, on Linux (specifically NixOS and Ubuntu), Python fails to access Git, even though it’s already installed on the host system.

Adding Git to the devenv environment dependencies resolves the issue, but this approach feels redundant, given that Git is already present on the host.