Command not found - Oh-My-Zsh

喜欢而已 提交于 2019-12-03 11:04:41

问题


I recently installed zsh and oh-my-zsh in my Mac. Now when I try to run a maven command from the terminal, I am getting the following error.

$ mvn install
zsh: command not found: mvn

I have installed Apache maven in /Applications directory. Currently my .zshrc file looks like below.

plugins=(git brew pip mvn mysql-macports python sublime tmux osx)

# ####################
# Maven Config Options
# ####################
export M2_HOME=/Applications/apache-maven-3.3.3
export PATH=$PATH:M2_HOME/bin

As seen above, I appended location of maven installation to the path. But I am still getting errors. Any help is appreciated.


回答1:


Just add:

source ~/.bash_profile

to .zshrc




回答2:


Question:

➜ ~ mvn

zsh: command not found: mvn

Answer:

step 1:

    vim ~/.zshrc

step 2:(Add at the end of the file)

    source ~/.bash_profile;

step 3:(Execution shell)

    > source ~/.bash_profile

You can use mvn :

➜ / mvn

[INFO] Scanning for projects... .......




回答3:


I had a similar problem after installing oh-my-zsh, but for adb command. Looks like the PATH is shortened when oh-my-zsh is installed. I solved it using following steps.

  1. Open the .zshrc file

    sudo nano ~/.zshrc
    
  2. Look for # User configuration

    Un-comment the following line:

    export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
    
  3. Save the file.

  4. source ~/.zshrc

Give this one a try for other similar command not found errors.




回答4:


  • First, as 4ae1e1 pointed out, you missed the $ in PATH=$PATH:M2_HOME/bin
  • Second, don't forget to run source ~/.zshrc to take the settings into effect instantly.



回答5:


vi ~/.zshrc

add source ~/.bash_profile to ~/.zshrc file, after the line source $ZSH/oh-my-zsh.sh

open up a new terminal tab and execute mvn, and it will start working.




回答6:


Combining other answers I got adb working on mac and zsh appending these two path lines to .zshrc:

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# this are for Android Studio adb:
export PATH=~/Android/sdk/tools:$PATH
export PATH=~/Android/sdk/platform-tools:$PATH



回答7:


As mentioned by @4ae1e1 in his comment, $ have to be added before M2_HOME while referring it in the PATH variable, as follows:

export M2_HOME=/Applications/apache-maven-3.3.3
export PATH=$PATH:$M2_HOME/bin/

Once added, as others suggested, source the ~/.zshrc file.



来源:https://stackoverflow.com/questions/33935281/command-not-found-oh-my-zsh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!