-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Using custom .env path only works from workspace root #40
Comments
I think the issue come from there: I believe the dotenv path provided is relative the current location where the nx command is ran. I quickly prototyped a workaround: import dotenv from "dotenv";
import { workspaceRoot } from "nx/src/utils/workspace-root";
import { CustomRunnerOptions } from "./types/custom-runner-options";
/**
* Initializes the environment variables.
*/
export const initEnv = (options: CustomRunnerOptions) => {
if (options.dotenv !== false) {
const dotenvConfig = {
path: options.dotenvPath?.replace("{workspaceRoot}", workspaceRoot),
};
console.log("🍕 dotenvConfig", dotenvConfig);
dotenv.config(dotenvConfig);
}
}; This way, the token I can submit a PR with it if you think this is the solution, but I'm note sure if it's the proper way to handle it, and there's other token to take into account. |
Seems to be fixed in the latest version. Not sure if it was a nx or this lib issue actually. |
Nevermind. The issue is still present (had the env files loaded elsewhere). sorry |
(moved from NiklasPor/nx-remotecache-azure#22)
Hello,
I don't know if I mis understood something, but I'm having troubles to configure the custom cache (using azure in my case).
When I run
pnpm nx run "@myorg/myproject:build" --verbose
from the root of the workspace, I can see cache populated.But if I run
cd packages/myproject
thenpnpm nx build --verbose
, the cache does not works.I get this error:
To setup the cache, I configured my root
nx.json
file like this:And I created a file
.env.secrets
sibling to thenx.json
file which contains:The full error is:
When running from the workspace root, I get, in the output
If I set up manually the env variable using
The cache always works, so I guess there's something wrong with the way the local
.env.secrets
file is read.I tried to explicitely targets the env file at workspace root using
"dotenvPath": "{workspaceroot}/.env.secrets"
, but there's no more success.If it matters,
pnpm why nx*
give:And my node version is 16.20.2
Thanks
The text was updated successfully, but these errors were encountered: