Ubuntu终端执行flutter doctor命令失败,报curl握手错误
flutter doctor on Ubuntu Hey there, I’ve dealt with this exact headache when setting up Flutter on Ubuntu—total roadblock, I know. Let’s walk through the most reliable fixes to get flutter doctor working again:
Update system packages and reinstall GnuTLS components
Outdated GnuTLS libraries are a common culprit here. Run these commands to refresh your system and fix any corrupted or old packages:sudo apt update && sudo apt upgrade -y sudo apt install --reinstall gnutls-bin libgnutls30After this, try running
flutter doctoragain to see if the error clears up.Switch curl to use OpenSSL instead of GnuTLS
Ubuntu’s default curl uses GnuTLS, which can sometimes have handshake issues with certain servers. Let’s swap it to OpenSSL:- Install the OpenSSL-backed curl package:
sudo apt install curl-openssl - Set it as the default curl version:
When prompted, select the option forsudo update-alternatives --config curlcurl-openssl(it’ll have a path like/usr/bin/curl-openssl).
- Install the OpenSSL-backed curl package:
Disable proxy settings temporarily
If you’re using a system or environment proxy, it might be interfering with the TLS handshake. Try unsetting proxy variables first:unset http_proxy https_proxyIf you have a GUI proxy enabled, head to Settings > Network > Proxy and toggle it off temporarily, then run
flutter doctoragain.Manually install the Flutter SDK
If all else fails, skip the curl-based installation entirely:- Download the latest Flutter SDK zip from the official site (you can use your browser for this).
- Extract it to a directory like
~/development/flutter(create the folder if it doesn’t exist). - Add Flutter’s bin directory to your PATH:
echo 'export PATH="$PATH:$HOME/development/flutter/bin"' >> ~/.bashrc # If you use Zsh, replace .bashrc with .zshrc - Reload your shell configuration:
source ~/.bashrc
Now run
flutter doctor—it should work without relying on curl for the setup.
内容的提问来源于stack exchange,提问作者Natarajan R

