2

I need some help to set environment variables on osX 12.0.1. I tried to edit .bash_profile (it doesnt exist), .zprofile and also a pllist approach. What irritates me, is that % env is not working in Terminal. Any hints for a newbee? Any help appreciated! :)

knickedom
  • 61
  • 1
  • 5
  • Firstly what shell are you running? (type `ps` in the terminal to see either `zsh` or `bash`). Then once you know that you can edit either `.zshrc` or `.bashrc`. – trojanfoe Nov 24 '21 at 14:47
  • Thank you for the hint. I run bash as I learned. .bashrc is not in my home directory. Should I create it? – knickedom Nov 24 '21 at 17:33
  • Yeah create it.. It's unusual you are running bash as zsh has been the default for a few versions of macOS. – trojanfoe Nov 24 '21 at 18:48
  • yeah, I created the file and and also .bash_profile and added the environment variables I needed to the ladder, now it works. Thanks a lot! – knickedom Nov 25 '21 at 20:10

1 Answers1

5

You can set the environment variable in ~/.zprofile

eval "$(/opt/homebrew/bin/brew shellenv)"
export PATH=/opt/apache-maven-3.5.2/bin:$PATH
export PATH=$PATH:/usr/local/go/bin
export JAVA_HOME=$(/usr/libexec/java_home)

This works fine for macOS Monterey

Programming-Lover
  • 1,177
  • 10
  • 14