godotenv: Doesn't support multiline vars

If I set something like this:

KEY='this is
a multiline
variable'

godotenv returns:

Can't separate key from value

Even though that’s a valid variable assignment.

I’m currently at work; will attempt a fix later this week.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 16
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Any updates on this? I am still having issues with the following env var:

EXAMPLE="-----BEGIN RSA PRIVATE KEY-----\n
abc\n
123\n
-----END RSA PRIVATE KEY-----"

I am still getting Failed to setup application - cannot continue: Can't separate key from value

@inoda You can probably just remove the actual line breaks (keeping the \n) and it should work.

I’ve received no complaints or bug reports about the pre-release, so I shall act as though absence of evidence is evidence of absence.

Pushing actual release today.

Screen Shot 2021-07-31 at 10 57 50 PM this works for me

This is now fixed via #156 (which was an expansion of #118)

Thanks @x1unix for the bulk of the work, and @austinsasko and @coolaj86 for some key suggestions.

Sorry it took so long… go’s no longer my daily driver, startup life, parent life, and frankly i’ve always been bad at “chores”

Release plan is to let it sit on main for a while, see if anyone raises regressions. I might do a prerelease version number, might not. Then will release as a minor version bump.

While most of the discussion on this is happening in #65 I’d rather talk about it here in case the ultimate solution is a different PR.

Given I use the ruby dotenv implementation as the informal spec a solution should follow the form of https://github.com/bkeepers/dotenv/commit/b3bd6357f80981941d78e51fe86aeaf66cdcc60f and expand newlines within double quotes only.