Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Julia environment (ENV) variable?

Tags:

julia

I am working through an example in GitHub.jl right now and trying to get user auth set up so that I can send API requests. One of the examples suggests doing ENV["GITHUB_AUTH"] instead of hard coding your API token however I am not sure how to define a variable like this. I tried looking for a usage example in help mode but it yielded the following with no example:

ENV

  Reference to the singleton EnvDict, providing a dictionary interface to system environment variables.

  (On Windows, system environment variables are case-insensitive, and ENV correspondingly converts all keys
  to uppercase for display, iteration, and copying. Portable code should not rely on the ability to
  distinguish variables by case, and should beware that setting an ostensibly lowercase variable may result
  in an uppercase ENV key.)
like image 592
logankilpatrick Avatar asked Jan 24 '26 04:01

logankilpatrick


1 Answers

As it turns out, setting up an ENV variable is as simple as:

ENV["GITHUB_AUTH"] = "my API key"

where "GITHUB_AUTH" is the name of the ENV variable you want to create.

If you want to read more about the limitations and proper use of ENV variables, you can check out the Julia docs.

like image 149
logankilpatrick Avatar answered Jan 26 '26 23:01

logankilpatrick