3

I'm trying to install flutter on my Mac, in order to do so I need to add a path to the .bash_profile. But when I run the command vim .bash_profile in the terminal ,I'm met with the following message.

# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH

export M2_HOME=/Applications/apache-maven-3.6.3
export PATH=$PATH:$M2_HOME/bin# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/sofie-amaliepetersen/opt/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/Users/sofie-amaliepetersen/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/sofie-amaliepetersen/opt/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/Users/sofie-amaliepetersen/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

This is my first time adding a PATH, I've tried looking at setting path in terminal But I'm not sure how it applies to my problem.

Any suggestions would be appreciated. Thanks

D. Ben Knoble
  • 4,273
  • 1
  • 20
  • 38
SAP
  • 57
  • 6
  • 1
    That's not a message; that's the contents of your `.bash_profile`. `vim` is a text editor. You might want to use `open -t .bash_profile` instead, which will open the file in TextEdit (most likely), which will be a bit easier to deal with. You can learn to use `vim` (or Emacs, or some other terminal-based editor) at a later time. – chepner Feb 14 '20 at 15:06
  • Okay thanks, can I just add the path on an empty line, using textEdit and save it? – SAP Feb 14 '20 at 15:10
  • Yes. `.bash_profile` is just a list of commands that get executed by the shell, one after another. – chepner Feb 14 '20 at 15:18

2 Answers2

2

Something important to note, is that if you're using Catalina (Or any of the newer forms os osx) your computer won't be using the bash shell by default (Although you'll still be able to update your bash_profile, it won't work, as the computer doesn't care). You'll need to update your zshrc instead of the bash profile. (just typing zsh in your terminal should be able to switch between them, showing you a % instead of a $)

The same process as with the bash profile can be used, and the same line too. Also if you WANT the computer to use the bash profile instead you can force it, but there's no realistic functionality changes between the two in 99% of applications.

ArthurEKing
  • 158
  • 2
  • 16
0

Anywhere in your .bash_profile, add this line

export PATH=$PATH:/your/new/path/to/add

This simply add /your/new/path/to/add to your existing $PATH

Francesco Gasparetto
  • 1,819
  • 16
  • 20
  • Correction: you can't put it just *anywhere* in the file; in particular, putting it between the "`if [ $? -eq 0 ]; then`" line and the "`fi`" line might cause trouble. I'd recommend putting it either at the beginning or the end, preferably with a blank line between it and what's already there (to make it more readable in case someone has to look at/fix it later). – Gordon Davisson Feb 15 '20 at 01:43