commands not found on zsh

前端 未结 16 1566
梦毁少年i
梦毁少年i 2020-12-04 06:30

I am using the z Shell (zsh) instead of the default bash, and something wrong happen so that all commands who used to work are no longer recognized:

<         


        
相关标签:
16条回答
  • 2020-12-04 07:07

    Restarting the terminal also made the trick for me.

    0 讨论(0)
  • 2020-12-04 07:08

    It's evident that you've managed to mess up your PATH variable. (Your current PATH doesn't contain any location where common utilities are located.)

    Try:

    PATH=/bin:/usr/bin:/usr/local/bin:${PATH}
    export PATH
    

    Alternatively, for "resetting" zsh, specify the complete path to the shell:

    exec /bin/zsh
    

    or

    exec /usr/bin/zsh
    
    0 讨论(0)
  • 2020-12-04 07:09

    if you are using macOS, try to follow this step

    if you write the code to export PATH in ~/.bash_profile then don't miss the Step 1

    Step 1:

    • make sure .bash_profile is loaded when your terminal is an open, check on your ~/.bashrc or ~/.zshrc (if you are using zsh), is there any code similar source ~/.bash_profile or not?. if not you can add manually with adding code source ~/.bash_profile in there
    • Also make sure this code is on your .bash_profile > export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin if it not in there, add that code into it

    Sep 2:

    • make sure the "Visual Studio Code.app" is in the right place > "/Applications" or "/Users/$(whoami)/Applications"
    • remove the old installed vs-code PATH rm -rf /usr/local/bin/code
    • open "Visual Studio Code.app"
    • CMD+Shift+P and then select "Shell Command: Instal "code" command in PATH"
    • restart your Mac and check by run this code -v, it should be work
    0 讨论(0)
  • 2020-12-04 07:10

    In your ~/.zsh config file include the path to your bash path file that contains your aliases. In my case it was including the line "source ~/.bash_profile" inside of ~/.zsh .

    0 讨论(0)
  • 2020-12-04 07:10

    As others have said, simply restarting the terminal after you've made changes should reset and changes you've made to your ~/.zshrc file. For instance after adding function to open visual studio:

    function code {  
        if [[ $# = 0 ]]
        then
            open -a "Visual Studio Code"
        else
            local argPath="$1"
            [[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
            open -a "Visual Studio Code" "$argPath"
        fi
    }
    

    I was able to use the keyword code to open the program from the command line.

    0 讨论(0)
  • 2020-12-04 07:13

    In my case I was using the variable path in lowercase!

    So in /etc/profile.d I was running a script that made use of the variable path. Because it was in lowercase I never thought it could mess up with the actual variable PATH. Be careful and do not use the variable path on your scripts.

    0 讨论(0)
提交回复
热议问题