skip to Main Content

I try to install flutter for the first time on my mac.

I followed the instructions on the flutter get-started and I downloaded the zip for apple silicon (step 1) and unzipped the content as step2 suggested.

then in step 3, i need to run this command:

export PATH="$PATH:`pwd`/flutter/bin"

So I run the command using where I was unzip the files: ~:

export PATH="$PATH:~/flutter/bin"

Then I restart the wrap terminal and try to run flutter but I got the error:

zsh: command not found: flutter

Why? What is missing?

enter image description here

enter image description here

I was try to solve it by doing what the accepted answer suggest

But still command not found.

enter image description here

enter image description here

2

Answers


  1. It seems like you’ve followed the initial steps correctly, but there might be an issue with how you’re setting the PATH environment variable. The zsh: command not found: flutter error typically occurs when the system cannot locate the "flutter" command in the directories listed in your PATH.

    Check Flutter Directory: First, make sure that you’re in the correct directory where you unzipped the Flutter SDK. You can use the ls command to list the contents of the current directory and verify that the flutter directory is present.

    Verify PATH Setting: When setting the PATH variable, using the ~ character might not work as expected. It’s better to use the full path to the Flutter directory. Here’s what you can do:

    Find the full path of your Flutter directory. You can use the pwd command when you’re inside the Flutter directory to get its full path.

    Update the PATH command accordingly. For example, if your Flutter directory’s full path is /Users/yourusername/flutter, then you should use:

    export PATH="$PATH:/Users/yourusername/flutter/bin"
    

    Replace yourusername with your actual username.

    Apply Changes: After updating the PATH command, save the changes to your shell profile configuration file. If you’re using zsh, the file is usually

    ~/.zshrc.

    You can use a text editor like nano or vim to edit the file:

    nano ~/.zshrc
    

    Add the export PATH line at the end of the file. Then save and close the file.

    Reload Configuration: After saving the changes, run the following command to apply the updated configuration:

    source ~/.zshrc
    

    Test Flutter: Now you should be able to run the flutter command without any issues:

    flutter --version
    
    Login or Signup to reply.
  2. Your export command does not make sense, since tilde-expansion occurs only if the tilde is at the start of an unquoted word.

    It should therefore be

    PATH="$PATH:$HOME/flutter/bin"
    

    or simpler

    path+=~/flutter/bin
    

    Since PATH is pretty sure exported anyway, you don’t need an explicit export.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search