Play Application Fails to Start with play.crypto.secret Parameter on Linux with Bash
The playframework production documentation states that one of the ways to pass the application secret to your application is through a system variable:
java -jar target/scala-2.XX/<yourprojectname>-assembly-<version>.jar -Dplay.crypto.secret=abcdefghijk
The recommended way to generate the application secret is by running:
sbt playGenerateSecret
Now if the secret generated contains a backtick like so:
QCY?tAnfk?aZ?iwrNwnxIlR6CTf:G3gf:90Latabg@5241AB`R5W:1uDFN];Ik@n
You’re in for a rude surprise when you try to start your application in a Bash shell:
java -jar target/scala-2.XX/<yourprojectname>-assembly-<version>.jar -Dplay.crypto.secret="QCY?tAnfk?aZ?iwrNwnxIlR6CTf:G3gf:90Latabg@5241AB`R5W:1uDFN];Ik@n"
The result with be a prompt indicating that you need to close the backtick:
>
instead of starting the application. Backticks are used for command expansion in Bash.
Now there are a couple of ways to workaround this:
- Escape the backtick:
QCY?tAnfk?aZ?iwrNwnxIlR6CTf:G3gf:90Latabg@5241AB\`R5W:1uDFN];Ik@n
- Replace it with a single quote:
QCY?tAnfk?aZ?iwrNwnxIlR6CTf:G3gf:90Latabg@5241AB'R5W:1uDFN];Ik@n
- Remove the backtick:
QCY?tAnfk?aZ?iwrNwnxIlR6CTf:G3gf:90Latabg@5241ABR5W:1uDFN];Ik@n
One thing to keep in mind with other Shells is that any special characters generated by the secret generator will probably have the same issues as Bash does.