zsh: parse error near `\n' when Adding AWS keys as environment variables

47,451

Solution 1

Most likely your keys contain some characters that have special meaning to zsh.

Use single quotes (') around your keys:

heroku config:add aws_access_key='<your access key>' aws_secret_key='<your secret key>'

If there are any single quotes in your keys write '\'' instead. For example, instead of

aws_access_key=stevie's key

write

aws_access_key='stevie'\''s key'

Explanation: anything between a pair of single qoutes is taken exactly as it is written, there will be no parameter or command substitution or escape codes. As the second ' ends the quote any ' you want to write has to be quoted in anoter way outside of a pair of single quotes, either \' or "'".

Solution 2

I have the same error, and resolved it . because I type like this

$ heroku config:set AWS_SECRET_KEY=<A2D3F4H5A6D7HJ8KHF9>

then got the error. change like That:

$ heroku config:set AWS_SECRET_KEY=A2D3F4H5A6D7HJ8KHF9

success

Solution 3

I was facing the same error while trying to do a commit in GitHub. Turns out, <> are reserved, so of course I could NOT name anything within them. Posting this for SEO purposes for whoever faces the same issue in GitHub.

Solution 4

You probably have some "special" characters in your Amazon access key or secret key which ZSH is interpreting. You usually need to "escape" these characters, but in this case you should be able to put the strings in quotes.

Try this instead (note the quotes around the values)

heroku config:add aws_access_key="<your access key>" aws_secret_key="<your secret key>"
Share:
47,451
Steve_D
Author by

Steve_D

Updated on July 09, 2022

Comments

  • Steve_D
    Steve_D almost 2 years

    I have a Rails app that I am hosting on Heroku, and hosting images on a Amazon S3. I am trying to add my Amazon credentials to my app using:

    heroku config:add aws_access_key:<your access key> aws_secret_key:<your secret key>
    

    I keep getting the error:

    zsh: parse error near `\n'
    

    I have no idea what the problem is.

  • Steve_D
    Steve_D about 10 years
    is there a way to override the zsh setting when running the command? I tried -f but that did not work.
  • Steve_D
    Steve_D about 10 years
    so I run the command in the exact format above with the single quotes and I know get the following error....... Usage: heroku config:set KEY1=VALUE1 [KEY2=VALUE2 ...] ! Must specify KEY and VALUE to set. My keys have no single quotes.
  • Adaephon
    Adaephon about 10 years
    Ok, from the error message I can see, that key-value-pairs are using = for assignments and not : as in your question. I modified the answer accordingly.
  • Steve_D
    Steve_D about 10 years
    thanks got it to work, it looks like if you use the quotes you do not need the < > around the keys. It was not working when I had the < > around the keys but worked without them using quotes.
  • Adaephon
    Adaephon about 10 years
    <> are often used to denote non-optional arguments in help texts. They are usually not part of the syntax and are thus, together with the text in between them, replaced by the actual value.
  • stdunbar
    stdunbar about 4 years
    The keys do not have a < or > in them - that was placeholder text.