2

i am trying to store my api keys in a variable via the terminal but i am unsure why it is not saving/storing my api keys.

  • for example, in the terminal when i type the below:

    export GMAIL_USERNAME="myname@gmail.com"

  • then when i type in env i can see the varaibale has been stored: enter image description here

  • but when i restart my terminal the variable GMAIL_USERNAME="myname@gmail.com" is no longer there

could one tell me where i am going wrong? all i would like to do is store in development my api secret keys in a variable. your help would be much appreciated

ARTLoe
  • 1,743
  • 2
  • 21
  • 54

1 Answers1

4

While you can persist environment variables by adding them to a script that gets called on shell startup, that approach has a few problems.

The biggest problem is that they are available globally across your shell, and not scoped to a project.
What happens if you have another project, and want to use a different gmail account?

A better solution is using dotenv or direnv and set those environment variables for the current project only.

Nils Landt
  • 3,104
  • 18
  • 18
  • didn't know about these solutions. It might become a problem, as you said, if OP decides to have another projects with the same env var, but, in that case I think it'll be easier just to drop that var into the environment file in the rails project (and set a different value per env, one for dev, one for prod and so on) – mr_sudaca Feb 07 '17 at 19:08