无法通过官方脚本安装Oh My Zsh,连接raw.githubusercontent.com超时
解决Oh My Zsh安装时raw.githubusercontent.com连接超时问题
以下是几个可行的解决方案:
修改本地hosts文件强制解析IP
- 查询raw.githubusercontent.com的有效公网IP(可通过本地
nslookup raw.githubusercontent.com命令或IP查询服务获取最新可用IP) - 编辑hosts文件:
- Linux/macOS:执行
sudo vim /etc/hosts - Windows:右键以管理员身份打开记事本,加载
C:\Windows\System32\drivers\etc\hosts文件
- Linux/macOS:执行
- 在文件末尾添加一行(示例IP,需替换为最新有效IP):
185.199.108.133 raw.githubusercontent.com - 保存文件后刷新本地DNS缓存:
- Linux:
sudo systemd-resolve --flush-caches - macOS:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder - Windows:打开管理员命令提示符执行
ipconfig /flushdns
- Linux:
- 重新运行Oh My Zsh的安装命令
- 查询raw.githubusercontent.com的有效公网IP(可通过本地
通过代理执行安装命令
如果有可用的HTTP/HTTPS代理,在curl或wget命令中指定代理参数:- curl方式:
sh -c "$(curl -fsSL -x http://代理地址:端口 https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" - wget方式:
sh -c "$(wget -e use_proxy=yes -e http_proxy=http://代理地址:端口 https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
- curl方式:
手动下载安装脚本执行
- 在能正常访问raw.githubusercontent.com的环境中,下载安装脚本:
curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -o install.sh - 将
install.sh文件传输到目标机器(可通过U盘、SCP等方式) - 给脚本添加执行权限:
chmod +x install.sh - 运行脚本完成安装:
./install.sh
- 在能正常访问raw.githubusercontent.com的环境中,下载安装脚本:
内容的提问来源于stack exchange,提问作者Vishesh Mistry
相关产品推荐
相关产品推荐

