#Bun does not read environment variables in bunfig.toml

1 messages · Page 1 of 1 (latest)

torn bison
#

I've been having a really hard time to get Bun to read environment variables.

I have this bunfig.toml:

[install.registry]
url = "https://artifacts.company.io/artifactory/api/npm/npm-virtual/:_auth=$ARTIFACTORY_NPM_SECRET"

This will not work regardless of the fact that the environment variable is set:

echo $ARTIFACTORY_NPM_SECRET
c3R....

I also tried putting it in .env either like this:

ARTIFACTORY_NPM_SECRET=c3R...

Or like this:

ARTIFACTORY_NPM_SECRET=${ARTIFACTORY_NPM_SECRET}

But neither of the above works.

I have confirmed that if I hard code the variable in bunfig it does work. I just need Bun to read the (preferably) actual environment variable (from process.env).

This works, but I can't use it:

[install.registry]
url = "https://artifacts.company.io/artifactory/api/npm/npm-virtual/:_auth=c3R..."
twilit grove
#

This is not on windows right

torn bison
#

I did a bit of debugging and it does indeed look like the variable isn't expanded, after running bun i and logging the request:

[Wed Mar 20 17:18:48 2024] {"Authorization":"Basic $ARTIFACTORY_NPM_SECRET","npm-auth-type":"legacy","If-None-Match":"26bf6e7a780b37287fe581c26bc132bc30f93956","Accept":"application\/vnd.npm.install-v1+json; q=1.0, application\/json; q=0.8, *\/*","Connection":"keep-alive","User-Agent":"Bun\/1.0.33","Host":"127.0.0.1:8089","Accept-Encoding":"gzip, deflate, br"}