From eae3ea09dce05eb5f2eee6b224292bcc80d7b6ac Mon Sep 17 00:00:00 2001 From: Tim Cosgrove Date: Mon, 30 Sep 2024 12:48:51 -0700 Subject: [PATCH 1/2] Even more debugging. --- packages/env-loader/src/env-file.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/env-loader/src/env-file.ts b/packages/env-loader/src/env-file.ts index 0b2e1492c..50e5f6689 100644 --- a/packages/env-loader/src/env-file.ts +++ b/packages/env-loader/src/env-file.ts @@ -4,12 +4,15 @@ import dotenvExpand from 'dotenv-expand' import { EnvVars } from '.' const loadEnvVarsFromPath = (path: string): EnvVars => { - let envVars = {} + const envVars = {} + // eslint-disable-next-line no-console + console.log(`trying to load vars from ${path}`) dotenvExpand.expand( dotenv.config({ - path, + path: path, override: true, processEnv: envVars, + debug: true, }) ) From 3292b217799aff222cbaea9bc41c464992abe123 Mon Sep 17 00:00:00 2001 From: Tim Cosgrove Date: Mon, 30 Sep 2024 13:53:58 -0700 Subject: [PATCH 2/2] Test access check on env. --- docker-run.sh | 1 + packages/env-loader/src/env-file.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/docker-run.sh b/docker-run.sh index 1e12f44bc..ceceb5ba2 100644 --- a/docker-run.sh +++ b/docker-run.sh @@ -1,3 +1,4 @@ #!/bin/sh ls -al envs +cat envs/.env.prod APP_ENV=$APP_ENV yarn build:preview && yarn start diff --git a/packages/env-loader/src/env-file.ts b/packages/env-loader/src/env-file.ts index 50e5f6689..7ff0758cf 100644 --- a/packages/env-loader/src/env-file.ts +++ b/packages/env-loader/src/env-file.ts @@ -27,6 +27,14 @@ export const getEnvFileVars = (appEnv?: string): EnvVars => { // Load env vars from `.env.${process.env.APP_ENV}` if it exists, // otherwise load env vars from `.env.local` if it exists. if (appEnv && fs.existsSync(`envs/.env.${appEnv}`)) { + try { + fs.accessSync(`envs/.env.${appEnv}`, fs.constants.R_OK) + // eslint-disable-next-line no-console + console.log('can read') + } catch (err) { + // eslint-disable-next-line no-console + console.error(`no access: ${err}`) + } return loadEnvVarsFromPath(`envs/.env.${appEnv}`) } else if (fs.existsSync('envs/.env.local')) { return loadEnvVarsFromPath(`envs/.env.local`)