Homebrew-使用總結(jié)

Homebrew-使用總結(jié)

報錯

  1. 執(zhí)行brew update命令,報錯:

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

    解決方法:

    1. 執(zhí)行:brew update --verbose

      執(zhí)行結(jié)果:

      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. 執(zhí)行:ls -al

      執(zhí)行結(jié)果:

      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. 執(zhí)行git fetch --prune origin

      執(zhí)行結(jié)果:

      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. 執(zhí)行git pull --rebase origin master

      執(zhí)行結(jié)果:

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

      執(zhí)行結(jié)果:

      Already up-to-date.
      
    7. 之后便可正常執(zhí)行其他命令了

      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. 查看網(wǎng)絡(luò)設(shè)置里當(dāng)前網(wǎng)絡(luò)socks代理服務(wù)器的IP和端口號,如下截圖:

    3. 添加git全局配置;

      1. 可以在終端先運行如下命令查看當(dāng)前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. 此時重新回去執(zhí)行安裝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
    

    解決方案:查詢資料后發(fā)現(xiàn)蘋果新系統(tǒng)安全提升,禁止了直接執(zhí)行遠(yuǎn)程腳本。 把腳本文件下載到本地來執(zhí)行就好:

    安裝的腳本下載
    卸載的腳本下載

    將對應(yīng)的腳本文件下載以后,在終端切換到下載腳本所在目錄并執(zhí)行 bash install.sh / bash uninstall.sh進(jìn)行安裝/卸載;

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容