1

I have read the documentation concerning falling back to environment variables at https://github.com/typesafehub/config/blob/master/HOCON.md#substitution-fallback-to-environment-variables. My understanding was that it would pickup any envars. So for instance, if from the shell I was able to do echo $HOSTNAME and see a non-empty response then HOCON should do that as well.

In my application.conf I have a line

akka.remote.netty.tcp.hostname = ${HOSTNAME}

However, my app is not happy with this and fails to start with.

/conf/application.conf: 9: Could not resolve substitution to a value:  ${HOSTNAME}

Is this a user issue? A shell issue? I am able to login as the user and echo $HOSTNAME

Tagging this scala and akka since that userbase probably has the most exposure to HOCON

bearrito
  • 2,217
  • 1
  • 25
  • 36

3 Answers3

2

The reason for HOCON not picking up the envar is that my app runs as a linux service (Centos 6.5) which clears away most environment variables.

See https://unix.stackexchange.com/questions/44370/how-to-make-unix-service-see-environment-variables for a relevant description of the issue

Community
  • 1
  • 1
bearrito
  • 2,217
  • 1
  • 25
  • 36
1

this is a shot in the dark, but are you using an older version of typesafe-config? maybe its a newer-ish feature? the feature seems to be advertised as you describe, but if you are pulling in typesafe-config as a transient dependency (say from akka), maybe you are getting an older version.

what happens if you remove the substitution in your .conf file (so parsing is successful) and then print out the contents of ConfigFactory.systemEnvironment()? for reference: http://typesafehub.github.io/config/latest/api/com/typesafe/config/ConfigFactory.html#systemEnvironment--

Michael Frank
  • 483
  • 1
  • 5
  • 7
1

HOSTNAME isn't an environment variable. It's a bash internal variable. See https://superuser.com/questions/132489/hostname-environment-variable-on-linux for more details.

Will Sargent
  • 4,346
  • 1
  • 31
  • 53