General Computing
macos environment-variables chromium
Updated Fri, 20 May 2022 01:29:33 GMT

Providing API Keys at Runtime for Chromium doesn't work

I installed Chromium for mac OS X.
When I launched the browser, I got a message stating "Google api keys are missing".
I followed the instructions on the "Chromium developers how-to". I have configured the needed API and got my API Credentials.
Then, I followed the instructions under the section of "Providing Keys at Runtime".

It seems like my attempts didn't work:

  • In order to add the variables into system's environment variables, I used the the command
    echo "GOOGLE_API_KEY=my_api_key" >> .bash_profile
    and then source .bash_profile.
    I did that to each variable stated in the document.
  • In order to check if the variabes were ser properly, I checked the .bash_profile file by using the command less .bash_profile and by the command printenv and the variables appear there.
  • I also did a restart to the computer, thinking it might be needed for those action to have an effect.
  • After I saw that didn't work, I tried adding the variables into system's environment variables by using the command nano .bash_profile - editing the file visually via the terminal and then saving the changes (although the previous changes did appear, I tried to delete them and then add them once again through this method).

I'm not sure what went wrong in that process, it seems like the API Keys are set properly as environment variables and yet chromium doesn't recognise them.

I would like to know what I should further do in order to solve this issue. Thank you.


Commands in your bash profile are only run if you start bash, and are only then available in a bash shell or its child processes. Since your environment variables are only available to bash, you need to start Chrome from bash.

First, open your .bash_profile in nano again and add the word export to the start of each line (e.g. export GOOGLE_DEFAU). This will make child processes of the shell inherit the environment variables. Then, close and reopen your Terminal to reload your .bash_profile.

To launch Chromium from bash in the Terminal, just run something of this form (location of your build may vary):


Comments (2)

  • +0 – Thank you, that worked. After launching chromium from bash, does it then acknowledge the environment variables for every session? Do I need to keep launching it from the terminal or it's just that I needed to do it once and from now on I'm able to launch it via spotlight and the dock? — Apr 26, 2016 at 08:06  
  • +0 – You'll have to launch from bash. However, you can make a script with the extension .command that'll be double-clickable in the Finder (e.g.… ). Just be sure to make it executable (chmod a+x /the/script.command). — Apr 26, 2016 at 14:32  

External Links

External links referenced by this document: