Build failing and getting clang error with uv and psycopg[c]==3.2.4 in build logs
colemandunn
PROOP

a year ago

Posting as much info as a can
error i am recieving:
``error: Failed to prepare distributions Caused by: Failed to download and buildpsycopg-c==3.2.4`

Caused by: Build backend failed to build wheel through build_wheel (exit status: 1)

[stdout]

error: command 'clang' failed: No such file or directory

✕ [stage-0 6/8] RUN --mount=type=cache,id=s/35642b86-2c05-4909-b637-090df8bb0998-/root/cache/uv,target=/root/.cache/uv python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install uv==0.4.30 && uv sync --no-dev --frozen
process "/bin/bash -ol pipefail -c python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install uv==$NIXPACKSUVVERSION && uv sync --no-dev --frozen" did not complete successfully: exit code: 2
```

Solved

14 Replies

colemandunn
PROOP

a year ago

full error VVVV

1340418867855622154


colemandunn
PROOP

a year ago

things i have tried:

  • include clang in nixpacks.toml
    -- this results in "error: collision between" for gcc and clang

  • removed nixPkgs entirely
    -- same clang error

other info:

  • my uv lock is up to date

  • my NIXPACKS_PYTHON_VERSION is 3.12.4

my nixpacks.toml file:

[phases.setup]
nixPkgs = ['...', 'ffmpeg']

colemandunn
PROOP

a year ago

initial build log
```[Region: us-west1]

==============

Using Nixpacks

==============

context: eb5accb6f2601307c25e9fa7ca834509

╔══════════════════════════════ Nixpacks v1.31.0 ══════════════════════════════╗

║ setup │ python312, postgresql_16.dev, gcc, ffmpeg ║

║──────────────────────────────────────────────────────────────────────────────║

║ install │ python -m venv --copies /opt/venv && . /opt/venv/bin/activate ║

║ │ && pip install uv==$NIXPACKSUVVERSION && uv sync --no-dev ║

║ │ --frozen ║

║──────────────────────────────────────────────────────────────────────────────║
```


colemandunn
PROOP

a year ago

pyproject.toml dependencies:

dependencies = [
    "coloredlogs==15.0.1",
    "django==5.0.4",
    "django-cors-headers==4.3.1",
    "django-debug-toolbar==4.3.0",
    "django-extensions==3.2.3",
    "django-filter==24.2",
    "django-storages[s3]==1.14.2",
    "djangorestframework==3.15.1",
    "djangorestframework-simplejwt[crypto]==5.3.1",
    "gtts==2.4.0",
    "gunicorn==21.2.0",
    "openai==1.59.5",
    "pgvector==0.2.5",
    "pillow==11.1.0",
    "psycopg[c]==3.2.4",
    "pydub==0.25.1",
    "pyperclip==1.9.0",
    "pytest==7.4.0",
    "pytest-django==4.7.0",
    "python-dotenv==1.0.1",
    "sentry-sdk[django]==1.45.0",
    "setuptools==75.3.0",
    "sounddevice==0.4.6",
    "soundfile==0.12.1",
    "stripe==8.1.0",
    "tiktoken==0.8.0",
    "uvicorn[standard]==0.28.0",
]

colemandunn
PROOP

a year ago

found solution! it is export CC=gcc found here https://github.com/astral-sh/uv/issues/8036

leaving this for posterity since uv is getting increasingly popular

however i am now getting a new error django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 or psycopg module so now i am investigating that…


colemandunn
PROOP

a year ago

from what i found on the web:https://stackoverflow.com/questions/70637715/improperlyconfigurederror-loading-psycopg2-module-s-e

and from chatgpt this seems to be a misconfigured postgres setup?

i can see the nixpack is automatically installing postgresql_16.dev but i am using psycopg[c] which is the faster local installation that has some prerequisites:
```a C compiler,

Python development headers (e.g. the python3-dev package).

PostgreSQL client development headers (e.g. the libpq-dev package).

The pg_config program available in the PATH.```

source: https://www.psycopg.org/psycopg3/docs/basic/install.html#local-installation

I did notice the django tutorial here: https://docs.railway.com/guides/django#configure-database-static-files--dependencies (there is a typo on this page btw. search for pyscog to find it) uses psycopg[binary] which according to psycopg docs: https://www.psycopg.org/psycopg3/docs/basic/install.html#binary-installation the "Binary packages are produced on a best-effort basis" and the local C version is faster

so is there anything i should be changing/adding to my nixPkgs or nixLibs?


colemandunn
PROOP

a year ago

continuing to search for the solution. might just go with a Dockerfile but I am interested on getting it deployed to railway by "default"


colemandunn
PROOP

a year ago

Build failing and getting clang error with uv and psycopg[c]==3.2.4 in build logs


colemandunn
PROOP

a year ago

by putting [phases.setup] nixPkgs = ["python3", "postgresql_16.dev", "clang", "ffmpeg"] i am now able to build without needing export CC=gcc however still getinng the django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 or psycopg module

i notices a more useful part of the error:```Attempts made:

  • couldn't import psycopg 'c' implementation: /lib/x8664-linux-gnu/libc.so.6: version `GLIBC2.38' not found (required by /nix/store/y44iixsj2fd1pcy8ny66809z8r6zlxag-postgresql-16.4-lib/lib/libpq.so.5)

  • couldn't import psycopg 'binary' implementation: No module named 'psycopg_binary'

  • couldn't import psycopg 'python' implementation: libpq library not found```


colemandunn
PROOP

a year ago

one more update i am able to get it working just find locally with DOCKER_DEFAULT_PLATFORM=linux/amd64 nixpacks build .. unsure why it does not work on railway


a year ago

Didn't see this thread earlier sorry @ZimFlare did u get it fixed?
Try downgrading Nixpacks, if that doesn't work use your own Dockerfile (way more reliable imo) depending on the project you can ask GPT to generate one for you.


a year ago

you can set nixpacks version in env vars
NIXPACKS_VERSION=1.29.1 (try this version)


colemandunn
PROOP

a year ago

Thank you! I ended up using docker. I was a little too determined to get it working on nixpacks haha


a year ago

!s


Status changed to Solved brody about 1 year ago


Status changed to Solved brody about 1 year ago


Loading...