The $VAR gotcha: why your command sees an empty value
Your shell expands $DATABASE_URL before getmyenv run starts, so the command gets an empty or old value. Quote it and let a shell inside run expand it.
Oct 10, 2026 · 3 min read

The symptom
bashnpx getmyenv run -- psql $DATABASE_URL
The context has DATABASE_URL, but psql gets no URL. If your shell already had a DATABASE_URL, it gets that old value instead.
Why it happens
Your shell expands $DATABASE_URL while it reads the line, before run starts. run sets the variable for the command, but the argument was already replaced. An unset variable disappears from the command, so psql receives no argument at all.
The same thing happens without getmyenv:
bashunset FOO FOO=x echo "[$FOO]" # prints [] FOO=x sh -c 'echo "[$FOO]"' # prints [x]
In the second line, the single quotes keep your shell away from $FOO. The inner sh starts with FOO set, and expands it then.
Fix in bash and zsh
bashnpx getmyenv run -- sh -c 'psql "$DATABASE_URL"'
Single quotes pass the text to run as it is. The inner sh starts inside run, with the context's values, and expands $DATABASE_URL there. Keep the double quotes inside, so a value with spaces stays one argument.
When the program reads the variable itself, you need no $ at all. Your own code, and Prisma or drizzle-kit configs that use DATABASE_URL, read it from the environment.
Fix in PowerShell
powershellnpx getmyenv run -- powershell -NoProfile -Command 'psql $env:DATABASE_URL'
PowerShell expands $env:DATABASE_URL in your line the same way. In single quotes it passes the text as it is, and the inner PowerShell expands it inside run. With PowerShell 7 installed, pwsh works as the inner shell too.
In cmd.exe, %DATABASE_URL% also expands before run starts. Use the PowerShell line above.
Check what the command gets
bashnpx getmyenv run --explain npx getmyenv run -- node -e "console.log(Boolean(process.env.DATABASE_URL))"
npx getmyenv run --explain lists every name and where it comes from. Never values. The second line prints true when the command has the variable, without printing the value. It works the same in bash, zsh and PowerShell.
Related docs: How run works, CLI reference