Search code examples
crystal-lang

Pass environment variables on compilation phase


In development i need to test console utility with server environment variables. Is there a way pass the environment variables and compile utility as if it were running on a server?

Something like a crystal prog.cr -- PROG_ENV=production?


Solution

  • You just set environment variables in your shell like for any other program and they will be available in the Crystal compiler. For example PROG_ENV=production crystal prog.cr