Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Predefined environment variables not passed to Nixpacks #2653

Open
sillvva opened this issue Jun 24, 2024 · 12 comments
Open

[Bug]: Predefined environment variables not passed to Nixpacks #2653

sillvva opened this issue Jun 24, 2024 · 12 comments

Comments

@sillvva
Copy link

sillvva commented Jun 24, 2024

Description

I pushed a PR to test predefined environment variables to a preview deployment on my Sveltekit app. The environment variables are being passed to Nixpacks as literal strings rather than being replaced with the predefined values.

I followed the instructions here: https://coolify.io/docs/knowledge-base/environment-variables

Minimal Reproduction (if possible, example repository)

Example variables:

TEST_URL=$COOLIFY_URL
PUBLIC_TEST_URL=$COOLIFY_URL

Build variable is checked. Is Literal? is not checked.

image

Exception or Error

The resulting Final Nixpacks plan looks like this:

Final Nixpacks plan: {
"providers": [],
"buildImage": "ghcr.io\/railwayapp\/nixpacks:ubuntu-1716249803",
"variables": {
"SOURCE_COMMIT": "8887ff2d43fa705c29557d55a2320a50b95f36eb",
...HIDDEN_REAL_VARIABLES...
"PUBLIC_TEST_URL": "$COOLIFY_URL",
"TEST_URL": "$COOLIFY_URL",
"CI": "true",
"NIXPACKS_METADATA": "node",
"NODE_ENV": "production",
"NPM_CONFIG_PRODUCTION": "false"
},

And the resulting environment variables look like this with console.table:

#14 13.85 Coolify check: process.env
#14 13.85
#14 13.85 ┌─────────────────┬────────────────┐
#14 13.85 │ (index) │ Values │
#14 13.85 ├─────────────────┼────────────────┤
#14 13.85 │ PUBLIC_TEST_URL │ '$COOLIFY_URL' │
#14 13.85 │ TEST_URL │ '$COOLIFY_URL' │
#14 13.85 └─────────────────┴────────────────┘

Version

v4.0.0-beta.297

@Aunali321
Copy link

i thought i was going crazy

@jacobschwantes
Copy link

Also facing this issue. The environment variable is getting set correctly in the container but $coolify_url is what gets passed if its marked as a build variable.

@lorenzomigliorero
Copy link
Contributor

Probably related to #2316

@seloElo
Copy link

seloElo commented Oct 24, 2024

Still have the issue today on last beta

@jycouet
Copy link

jycouet commented Dec 2, 2024

I think that this is fixed (I'm on v4.0.0-beta.373)

@peaklabs-dev
Copy link
Member

This issue should be resolved in the latest version. If you're still experiencing this issue, please reopen or create a new issue with updated details.

@sillvva
Copy link
Author

sillvva commented Dec 2, 2024

I am still having this issue on 4.0.0-beta.373

Example environment variable (build variable checked, literal not checked):

PUBLIC_TEST_URL=$COOLIFY_URL

Image

In the "Final Nixpacks Plan"

"PUBLIC_TEST_URL": "$COOLIFY_URL",

Logged output during build:

#14 14.79 │ PUBLIC_TEST_URL       │ '$COOLIFY_URL'

For the record, the above is a test variable on a SvelteKit app. During the build, I call a console.table after parsing the environment variables with a schema library.

@peaklabs-dev peaklabs-dev reopened this Dec 2, 2024
@peaklabs-dev peaklabs-dev added this to the v4.0.0 Stable Release milestone Dec 2, 2024
@99Arrzel
Copy link

Is there any workaround for this at the moment?
This is annoying for PR deployments lol

@BedroomDev
Copy link

still doesnt work on 4.0.0-beta.380 newest version to date

  • UndefinedVar: Usage of undefined variable '$NIXPACKS_PATH' (line 18)
    2025-Jan-15 14:55:41.022784

@sillvva
Copy link
Author

sillvva commented Jan 15, 2025

I think I saw a potential fix coming in 381. It's not released yet.

I noticed it at about 0:04 on the video
https://bsky.app/profile/heyandras.dev/post/3lfp73cifx62e

@viktorkuts
Copy link

I think I saw a potential fix coming in 381. It's not released yet.

I noticed it at about 0:04 on the video https://bsky.app/profile/heyandras.dev/post/3lfp73cifx62e

Nope, I tried 381 and even 382 and that didn't fix any issues, still ongoing

@viktorkuts
Copy link

Adding to this, it seems as if it is only limited to static pages, like using Vite, Svelte etc.
Whenever I dump the process env in my frontend (Vite & React) static build, I get no COOLIFY_ or they stay literals as $COOLIFY_
However in my backend (Java Spring Boot), the env dump has all the predefined variables, without even needing to bind them to a project variable.

One thing to note however, when I dump the envs in the terminal of the frontend in coolify, I do see the predefined variables, which is more how the backend deployment behaves. It's very strange behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants