问题
When working with a Google API's "credentials.json" file, we sometimes need to store the entire contents in an environment variable. The following approach works on Mac OS and in Git Bash on Windows:
export LOCAL_CREDS="$(< auth/credentials.json)"
When we need to set this same environment variable on a heroku server, the following approach works on a Mac:
heroku config:set REMOTE_CREDS="$(< auth/credentials.json)"
... but on Git Bash on Windows it produces the following error:
heroku config:set REMOTE_CREDS="$(< auth/credentials.json)"
#> 'C:\Program' is not recognized as an internal or external command, operable program or batch file.
I tried specifying the absolute filepath instead of a relative one, passing a JSON string directly (see below), but none of these approaches work.
heroku config:set FOO_JSON='{"abc":"bcd","cde":"def"}'
#> 'C:\Program' is not recognized as an internal or external command, operable program or batch file.
How can we set these JSON-like environment variables on a heroku server via Git Bash on Windows?
FYI:
heroku --version
#> heroku/7.26.2 win32-x64 node-v11.14.0
which heroku
#> /c/Program Files/heroku/bin/heroku
来源:https://stackoverflow.com/questions/56859583/how-to-set-json-object-as-heroku-environment-variable-on-git-bash