Homebrew-使用总结

Homebrew-使用总结

报错

  1. 执行brew update命令,报错:

    fatal: Could not resolve HEAD to a revision
    Already up-to-date.
    

    解决方法:

    1. 执行:brew update --verbose

      执行结果:

      Checking if we need to fetch /opt/homebrew...
      Checking if we need to fetch /opt/homebrew/Library/Taps/homebrew/homebrew-core...
      Fetching /opt/homebrew...
      Updating /opt/homebrew...
      Branch 'master' set up to track remote branch 'master' from 'origin'.
      Switched to and reset branch 'master'
      Your branch is up to date with 'origin/master'.
      Switched to and reset branch 'stable'
      Current branch stable is up to date.
      
      Updating /opt/homebrew/Library/Taps/homebrew/homebrew-core...
      fatal: Could not resolve HEAD to a revision
      
      Already up-to-date.
      
    2. 打开报错路径:cd /opt/homebrew/Library/Taps/homebrew/homebrew-core

    3. 执行:ls -al

      执行结果:

      total 0
      drwxr-xr-x   3 hsh  admin   96 10 14 16:27 .
      drwxr-xr-x   3 hsh  admin   96 10 14 16:27 ..
      drwxr-xr-x  12 hsh  admin  384 10 15 14:12 .git
      
    4. 执行git fetch --prune origin

      执行结果:

      remote: Enumerating objects: 3, done.
      remote: Counting objects: 100% (2/2), done.
      remote: Total 3 (delta 2), reused 2 (delta 2), pack-reused 1
      Unpacking objects: 100% (3/3), 1.54 KiB | 92.00 KiB/s, done.
      From https://github.com/Homebrew/homebrew-core
       * [new branch]              update-tflint.rb-1634223541 -> origin/update-tflint.rb-1634223541
      
    5. 执行git pull --rebase origin master

      执行结果:

      From https://github.com/Homebrew/homebrew-core
       * branch                    master     -> FETCH_HEAD
      
    6. 成功后即可执行更新:brew update

      执行结果:

      Already up-to-date.
      
    7. 之后便可正常执行其他命令了

      eg:brew install rbenv ruby-build

  2. 安装或更新brew报错:

    fatal: unable to access ‘https://github.com/Homebrew/brew/’: LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
    

    解决方法:

    1. 需要翻墙:

    2. 查看网络设置里当前网络socks代理服务器的IP和端口号,如下截图:

    3. 添加git全局配置;

      1. 可以在终端先运行如下命令查看当前git配置:cat ~/.gitconfig,看是否有如下两项配置:

        http.proxy=socks5://127.0.0.1:6666
        http.sslbackend=openssl
        
      2. 如果没有,在终端分别运行如下两条命令添加配置:

        git config --global http.sslBackend "openssl"
        
        // 端口号请使用自己本地socks端口号
        git config --global http.proxy "socks5://127.0.0.1:1189"
        
      3. 这时再查看gitconfig的配置,就有如下截图中的配置项了:

        [http]
            sslBackend = openssl
            proxy = socks5://127.0.0.1:1080
        
    4. 修改:hosts文件:路径在:/private/etc/hosts:添加:

      140.82.114.4 github.com
      185.199.108.133 raw.githubusercontent.com
      185.199.109.133 raw.githubusercontent.com
      185.199.110.133 raw.githubusercontent.com
      185.199.111.133 raw.githubusercontent.com
      
    5. 此时重新回去执行安装brew的命令就可以成功安装brew软件了;

    6. 如果之前安装失败过,此时再安装可能会遇到错误,需要先卸载再安装;

    7. 安装成功以后想撤销刚刚对gitconfig的配置,在终端运行如下命令:

      git config --global --unset  http.sslBackend
      git config --global --unset http.proxy
      
  3. 报错:

    curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443 或者 fatal: unable to access github.com/Homebrew/br…: LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
    

    解决方案:查询资料后发现苹果新系统安全提升,禁止了直接执行远程脚本。 把脚本文件下载到本地来执行就好:

    安装的脚本下载
    卸载的脚本下载

    将对应的脚本文件下载以后,在终端切换到下载脚本所在目录并执行 bash install.sh / bash uninstall.sh进行安装/卸载;

你可能感兴趣的:(Homebrew-使用总结)