devbox icon indicating copy to clipboard operation
devbox copied to clipboard

pg_config does not work in a devbox environment

Open ronflima opened this issue 10 months ago • 2 comments

What happened?

After installing the devbox environment, I was unable to build psycopg2 Python driver because pg_config fails consistently. It happens for every single PostgreSQL installation I have tried.

Links look to be built correctly, but pg_config keeps failing consistently. It looks like the way devbox is building the PATH is not suitable for pg_config workings.

Steps to reproduce

  1. devbox init
  2. devbox add postgresql
  3. devbox add [email protected]
  4. devbox install
  5. devbox shell
  6. . ./.venv/bin/activate
  7. pip install psycopg2

Command

add

devbox.json

{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.14.0/.schema/devbox.schema.json",
  "packages": [
    "postgresql@latest",
    "[email protected]"
  ],
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!' > /dev/null"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}

Devbox version

0.14.0

Nix version

nix (Nix) 2.24.7

What system does this bug occur on?

Linux (x86-64)

Debug logs

No response

ronflima avatar Mar 04 '25 22:03 ronflima

Workaround

There is a workaround for this. I had to install postgresql-client-common in my system, using the standard package manager in order to have psycopg2 correctly built. As my understanding, it shouldn't be necessary.

ronflima avatar Mar 05 '25 07:03 ronflima

According to upstream, this should be resolvable using devbox add postgresql.pg_config

However, when I try this locally, I get an error:

time=2025-11-10T10:29:39.116-07:00 level=DEBUG source=go.jetify.com/devbox/internal/shellgen/flake_plan.go:143 msg="creating new patch flake" flake.inputs.devbox=github:jetify-com/devbox/0.16.0 flake.inputs.nixpkgs-glibc="github:NixOS/nixpkgs/832e3b6db48508ae436c2c7bfc0cf914eac6938e?narHash=sha256-uTpzDHRASEDeFUuToWSQ46Re8beXyG9dx4W36FQa0%2Fc%3D" flake.inputs.nixpkgs-f4b140=github:NixOS/nixpkgs/f4b140d5b253f5e2a1ff4e5506edbf8267724bde flake.outputs=[python312]
⣾ Computing the Devbox environment...
time=2025-11-10T10:29:39.120-07:00 level=DEBUG source=go.jetify.com/devbox/internal/nix/nix.go:83 msg="running print-dev-env cmd" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/Users/josephsmith/.local/share/devbox/global/default/.devbox/gen/flake"
time=2025-11-10T10:29:39.120-07:00 level=DEBUG source=go.jetify.com/devbox/internal/nix/nix.go:84 msg="nix command starting" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/Users/josephsmith/.local/share/devbox/global/default/.devbox/gen/flake"
time=2025-11-10T10:29:39.208-07:00 level=DEBUG source=go.jetify.com/devbox/internal/nix/nix.go:84 msg="nix command exited" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/Users/josephsmith/.local/share/devbox/global/default/.devbox/gen/flake" cmd.path=/✓ Computed the Devbox environment.

Error: There was an error installing nix packages
source: nix: command error: nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/Users/josephsmith/.local/share/devbox/global/default/.devbox/gen/flake: attribute 'nixpkgs-832e3b.url' already defined at /nix/store/1mpr0rba1gcn4c3arv60yaks5ri4jk73-source/flake.nix:9:6: exit code 1

time=2025-11-10T10:29:39.208-07:00 level=ERROR source=go.jetify.com/devbox/internal/boxcli/midcobra/debug.go:68 msg="command error" stderr="error: attribute 'nixpkgs-832e3b.url' already defined at /nix/store/1mpr0rba1gcn4c3arv60yaks5ri4jk73-source/flake.nix:9:6\n       at /nix/store/1mpr0rba1gcn4c3arv60yaks5ri4jk73-source/flake.nix:10:6:\n            9|      nixpkgs-832e3b.url = \"github:NixOS/nixpkgs/832e3b6db48508ae436c2c7bfc0cf914eac6938e\";\n           10|      nixpkgs-832e3b.url = \"github:NixOS/nixpkgs/832e3b6db48508ae436c2c7bfc0cf914eac6938e\";\n             |      ^\n           11|    };\n" execid=9ba7b440f017491588830c283b173c7e stack=<nil>```

tml-adobe avatar Nov 10 '25 17:11 tml-adobe