x-cmd / x-cmd

X bootstrap 1000+ tools and scripts.
https://x-cmd.com
597 stars 19 forks source link

["BUG"] Unset brew mirror not working #74

Open iandol opened 1 week ago

iandol commented 1 week ago

Describe the bug

I used x brew mirror set tuna which works well in China but travelling back to europe it doesn't work well. So I tried x brew unset, but brew update fails:

ε ➪ x brew mirror current 
HOMEBREW_API_DOMAIN=
HOMEBREW_BOTTLE_DOMAIN=
HOMEBREW_BREW_GIT_REMOTE=
HOMEBREW_CORE_GIT_REMOTE=
GIT_DIR=https://github.com/Homebrew/brew

Seneca » ~ 
ε ➪ brew update
==> Updating Homebrew...
fatal: unable to access 'https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git/': Failed to connect to mirrors.tuna.tsinghua.edu.cn port 443 after 75365 ms: Couldn't connect to server
Error: Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-core failed!
==> Updated Homebrew from dfe28d8944 to 019b0f50fb.
No changes to formulae or casks.
Exception: brew exited with 1
  [tty 2]:1:1-11: brew update

The problem is the git repo is still set to tuna:

Seneca » …/homebrew-core on  master via 💎 v3.3.3 
ε ➪ git remote -v
origin  https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git (fetch)
origin  https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git (push)

System (please complete the following information):

Expected behavior unset reverts brew back to the standard repo.

iandol commented 1 week ago

This fixes the error (for homebrew core):

Seneca » …/homebrew-core on  master via 💎 v3.3.3 
ε ➪ git remote set-url origin https://github.com/Homebrew/homebrew-core.git
edwinjhlee commented 1 week ago

Thanks. We will take a look at it.

lunrenyi commented 1 week ago

Starting from version 4.10.0, we will use the git -C "$(brew --repo [repo_name])" remote set-url origin [new_url] method to restore the remote URL of the repository in order to fix this issue.

lunrenyi commented 1 week ago

We discovered a cleaner method of setting download sources using Homebrew's environment files, so we'll be adjusting the implementation of x brew mirror set/unset in the new version.