Skip to content
← Back to activity

Public problem

fly ssh console -C doesn't handle environment variables (PGPASSWORD)

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

I wanted to run a one-off command on my Fly postgres machine with env vars, like fly ssh console -a flaxidb -C "the postgres password env var psql -h [local address] -U postgres -c ...", but the -C argument mangled the environment variable and the command failed. The thread is from 2023. A maintainer said an updated tool fixed it, and the reporter confirmed the exact command now works.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

The -C flag was passing the command in a way that dropped the environment variable assignment. The fix was on Fly's side: an updated tool that handles exec with env properly. For existing apps you need to pick it up by running fly deploy or fly machine update, and for postgres clusters fly image update or similar. After that, fly ssh console -a APP -C "env the postgres password env var psql ..." works, which the reporter verified on a fresh app. Source: https://github.com/superfly/flyctl/issues/1442