mud icon indicating copy to clipboard operation
mud copied to clipboard

consider loading `.env.$FOUNDRY_PROFILE` in deploy

Open frolic opened this issue 10 months ago • 3 comments

would be nice to be able to run only

mud deploy --profile rhodolite

and it load .env.rhodolite for rhodolite specific private key, etc.

frolic avatar Feb 04 '25 16:02 frolic

also need to add --profile (and prob other deploy options) to mud dev-contracts

frolic avatar Feb 05 '25 10:02 frolic

can do env loading right after this line https://github.com/latticexyz/mud/blob/6bd1695fe986f90478cfb8fe7fcc00a7a7df3e04/packages/cli/src/runDeploy.ts#L69 something like

dotenv.config({ path: [`.env.${profile}`] });

frolic avatar Feb 05 '25 10:02 frolic

actually, it's unclear if that's the right path, because we will have already loaded .env into the env by then

if someone had PRIVATE_KEY set in .env it wouldn't be overridden by PRIVATE_KEY in .env.$profile

and if we use dotenv.config({ override: true, ... }) then we potentially override any env vars passed directly into the command like PRIVATE_KEY=... mud deploy

so may need to parse the profile arg earlier or move the dotenv.config(...) call later to include both env files at the same time

frolic avatar Feb 05 '25 10:02 frolic