You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

克隆Flutter SDK时遇错误:MacBook终端执行命令报错求助

Troubleshooting Flutter SDK Clone Errors on MacBook Terminal

Hey there, sorry to hear you're running into snags cloning the Flutter SDK via your MacBook's terminal—let's work through the most common fixes to get you sorted:

GitHub connectivity can be spotty depending on your location or network setup. Try these tweaks:

  • Use Flutter's optimized mirrors (great if you’re in a region with limited GitHub access):
    First set temporary environment variables in your terminal:
    export PUB_HOSTED_URL=https://pub.flutter-io.cn
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
    
    Then run the stable branch clone command again:
    git clone https://github.com/flutter/flutter.git -b stable
    
  • Switch between HTTPS and SSH: If HTTPS fails, give SSH a shot (just make sure you set up GitHub SSH keys first—see section 4):
    git clone git@github.com:flutter/flutter.git -b stable
    

2. Resolve File Permission Errors

Cloning to system-protected folders (like /usr/local) often triggers access denied errors:

  • Clone to a user-owned directory (this is the recommended approach):
    # Create a dedicated development folder in your home directory
    mkdir -p ~/development
    cd ~/development
    # Clone Flutter here
    git clone https://github.com/flutter/flutter.git -b stable
    
  • If you need a system folder: Use sudo for temporary admin access, then fix folder ownership to avoid future headaches:
    sudo git clone https://github.com/flutter/flutter.git -b stable /usr/local/flutter
    sudo chown -R $(whoami):staff /usr/local/flutter
    

3. Update Your Git Version

MacOS ships with an older Git version by default, which can clash with GitHub's latest protocols:

  • If you use Homebrew, update Git in one line:
    brew install git
    
  • Restart your terminal, then verify the update:
    git --version
    
    Aim for Git 2.20.0 or newer for full compatibility.

4. Fix SSH Authentication Issues (For SSH Clones)

"Permission denied" errors with SSH usually mean your MacBook's SSH key isn’t linked to your GitHub account:

  1. Check if you already have an SSH key:
    ls -al ~/.ssh
    
  2. If no key exists, generate a new one (replace with your GitHub email):
    ssh-keygen -t ed25519 -C "your-github-email@example.com"
    
  3. Add the key to your SSH agent:
    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_ed25519
    
  4. Copy the public key to your clipboard:
    cat ~/.ssh/id_ed25519.pub | pbcopy
    
  5. Paste this key into your GitHub account’s SSH and GPG keys settings, then retry the clone.

5. Clean Up Partial Clones

If your clone was interrupted mid-process, leftover files can cause weird errors:

  • Delete the incomplete Flutter folder:
    rm -rf flutter
    
  • Then re-run the clone command from scratch.

If none of these fixes work, share the exact error message you’re seeing (e.g., "fatal: unable to access 'https://github.com/flutter/flutter.git/': SSL certificate problem")—that will help narrow down the issue even more!

内容的提问来源于stack exchange,提问作者Shubham Sejpal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:51:00