question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to escape multiline values in .env file

See original GitHub issue

First of all, thanks a million for this action, it’s super useful.

I was wondering how to escape multiline env vars. let’s say I have a cert that I want to pass to my .env file from a github secret. This works locally because I can wrap the cert in quotes in my local .env file. How can I accomplish the same thing with this action? I don’t think it does this by default, because right now I’m getting the following error when I try to run docker-compose

Run docker compose -f docker-compose.yml -f production.yml build
unexpected character "+" in variable name near "***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\n***\nPOSTGRES_DB=***\nPOSTGRES_HOST=***\nPOSTGRES_PASSWORD=***\nPOSTGRES_PORT=***\nPOSTGRES_USER=***\nREDIS_HOST=***\nREDIS_PASSWORD=***\nREDIS_PORT=***\n"
Error: Process completed with exit code 1.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
justintempscommented, Jun 29, 2022

I’m specifically thinking of an RSA key or some similar value where the line breaks are meaningful and have to be encoded in some way.

In my instance, I was using dotenv in a Node.js project which supports wrapping multiline variables in quotes like this.

PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
...
HkVN9...
...
-----END DSA PRIVATE KEY-----"

I guess in this situation, create-envfile needs to know if you’re intentionally passing in a variable that has linebreaks or if you’re not and it should through an error.

This seems a little hacky, but may be just adding something to the prefix like:

envkey_multiline_SECRET_KEY
0reactions
justintempscommented, Jul 1, 2022

Yea @AngelOnFira that would be awesome.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Export a Multi-line Environment Variable in Bash ...
I'm using a .env file with a project in Glitch, and wrapping the key in single quotes was the only solution that worked...
Read more >
multiline environment variable in /etc/environment - Super User
Title says it all really. I'm trying to set an RSA private key in /etc/environment.
Read more >
Multiline environment variable support : IDEA-185315
1. Create any build configuration, for instance, for Python script. · 2. Go to Environment->Environment variables · 3. Add a variable TEST_VAR and...
Read more >
How to create .env multiline variable - docker - Server Fault
Locally I just export MY_ENV_VAR=$(cat my_key.pem) , but on the server, it needs to be inside the .env file and needs to contain...
Read more >
Dotenv File Format — Dotenvy v0.7.0 - HexDocs
.env files (a.k.a. "dotenv") store key-value pairs in a format descended from ... The following character strings will be interpreted (i.e. escaped) as ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found