Search code examples
linuxterminaloh-my-zshzshrc

Adding flutter Path to .zshrc causes error in iTerm with oh-my-zsh


I am going to add Path of flutter to .zshrc permanently.

when I installed either iTerm or oh-my-sh, it rewritten .zshrc file. Now if I add export PATH=$HOME/coding/flutter/env/flutter/bin and enter source ./.zshrc on iTerm, I am getting the following errors.

/Users/mine/.oh-my-zsh/oh-my-zsh.sh:56: command not found: mkdir
/Users/mine/.oh-my-zsh/oh-my-zsh.sh:117: command not found: rm
zrecompile:99: command not found: wc
zrecompile:135: command not found: mv
detect-clipboard:33: command not found: uname
nvm:7: command not found: tr
nvm:7: command not found: tr

How can I add other path to .zshrc ?

If I add the path, I can run flutter on terminal but many other commands are not found. I tried to add the export to .zprofile or some other files but still the same error.


Solution

  • let's say, A='apple'. if you assign A='banana', A is 'banana' now.

    But If you expand the A (which has apple) before assign banana, A would hold both. It would be A=$A:banana.

    In this case, A will apple:banana. this is what you need.

    You needed to hold both. But what you did is A=banana

    I suggest putting this line below in your .zshrc.

    export PATH=$PATH:$HOME/coding/flutter/env/flutter/bin
    

    The line will expand the current $PATH, which doesn't have the flutter PATH, before assigning $HOME/coding/flutter/env/flutter/bin.