Homebrew的安装遇到400 Bad Request错误

文章详细介绍了在安装Homebrew时遇到curl请求错误400BadRequest的解决方案,通过替换命令行参数成功解决问题,并分享了解决过程中的关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天安装Homebrew时用如下命令:    

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

出现 

curl: (22) The requested URL returned error: 400 Bad Request
错误,搜了下改用如下命令就可以成功安装:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 4096; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80; listen [::]:80; server_name _; autoindex on; root /usr/share/nginx/html; index index.php index.html; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; include fastcgi_params; } } # Settings for a TLS enabled server. # # server { # listen 443 ssl http2; # listen [::]:443 ssl http2; # server_name _; # root /usr/share/nginx/html; # # ssl_certificate "/etc/pki/nginx/server.crt"; # ssl_certificate_key "/etc/pki/nginx/private/server.key"; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 10m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # # # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # # error_page 404 /404.html; # location = /40x.html { # } # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # } }
06-25
### Homebrew 安装常见问题及解决方案 #### 权限问题 在安装 Homebrew 时,有时会遇到权限不足的问题。这通常是因为尝试将文件写入受保护的目录或未正确设置用户的管理员权限。可以通过以下方法解决此问题:确保以具有管理员权限的用户身份运行安装脚本,并避免手动更改 `/usr/local` 或其他目标路径的权限[^4]。 如果仍然出现问题,可以尝试删除已部分安装的内容并重新开始: ```bash sudo rm -rf /opt/homebrew/* /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` #### Xcode 命令行工具缺失 某些情况下,在安装 Homebrew 及其依赖项前,需要先确认是否安装了 Xcode 命令行工具。缺少该工具可能导致后续操作失败。验证和安装命令如下所示: ```bash xcode-select --install ``` 上述命令会在必要时启动图形界面提示完成安装过程[^2]。 #### 环境变量冲突 当系统中存在多个版本的包管理器或其他环境干扰因素时,可能引发不可预见的行为。建议清理旧版残留数据后再继续安装新实例;另外也要注意 `.zshrc`, `.bash_profile` 文件里 PATH 设置顺序合理以免覆盖默认值造成混乱[^3]。 #### 特定平台适配 (macOS vs Linux) 虽然大多数资料集中讨论的是 macOS 下的应用场景, 实际上 Homebrew 同样支持基于 Linux 的发行版. 不过两者间可能存在细微差异需要注意调整相应参数来匹配各自操作系统特性需求[^1]. 对于Linux系统的使用者来说,则需采用linuxbrew仓库地址来进行初始化部署工作流程: ```bash /bin/bash -c "$(curl -fsSL https://github.com/Linuxbrew/install/raw/master/install.sh)" ``` --- ### 示例代码片段展示正常安装方式 以下是标准推荐用于初次接触者的自动化脚本形式之一 : ```bash #!/bin/sh # 此处提供了一个简单易懂的例子说明如何正确引入远程shell script 并执行. set -e echo "Starting Homebrew installation..." /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" </dev/tty >/dev/tty 2>/dev/tty || true ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值