Cashed SSH host for github.com

$ brew --version
Homebrew 2.3.0-16-g0305001
Homebrew/homebrew-core (git revision ffb73; last commit 2020-06-01)

$ system_profiler SPSoftwareDataType
System Version: macOS 10.15.5 (19F101)

For some time I had a “custom” name for github.com host In my ~/.ssh/config:

Host github-myname
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile /path/to/key

Everything was working fine.

But recently I’ve changed this “custom” name from github-myname to just github.com. And now Homebrew commands started to fail with the following errors:

ssh: Could not resolve hostname github-myname: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Error: Fetching /usr/local/Homebrew failed!
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services failed!

So apparently Homebrew relies on some “cashed” values for SSH hosts (or perhaps has its own SSH config)?

Just in case, I’ve checked /usr/local/Homebrew/.git/config contents:

config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = true
	autocrlf = false
[remote "origin"]
	url = https://github.com/Homebrew/brew.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[homebrew]
	analyticsmessage = true
	donationmessage = true
	caskanalyticsmessage = true
	analyticsdisabled = true
	devcmdrun = true
[branch "master"]
	remote = origin
	merge = refs/heads/master

And there the remote is https://github.com/Homebrew/brew.git, so it should work.

What should I do to clear that cache and to make Homebrew use the current values from my ~/.ssh/config?

What do brew config and brew doctor output?

Yeah, should’ve posted those right away. Here they are:

brew config
HOMEBREW_VERSION: 2.3.0-16-g0305001
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 03050019dff2c35ee1007fa97faaa3b50b0c8588
Last commit: 4 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: ffb73d6ff3af0ba294bca890edaf00ee9e6cc6d0
Core tap last commit: 4 weeks ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_MAKE_JOBS: 12
HOMEBREW_NO_ANALYTICS: set
CPU: dodeca-core 64-bit kabylake
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
Clang: 11.0 build 1103
Git: 2.24.3 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 10.15.5-x86_64
CLT: 11.5.0.0.1.1588476445
Xcode: 11.5

and

brew doctor
Warning: Some installed formulae were deleted!
You should find replacements for the following formulae:
  python@2
  3.7.1
  3.7.1
  3.7.1
  3.7.1
  3.7.1
  3.7.1
  3.7.1
  3.7.1
  pygtk
  3.7.2
  3.7.2
  3.7.2
  3.7.2
  3.7.2
  3.7.2
  3.7.2
  3.7.2
  pygobject

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/libgvplugin_core.6.dylib
  /usr/local/lib/libgvplugin_dot_layout.6.dylib
  /usr/local/lib/libgvplugin_gd.6.dylib
  /usr/local/lib/libgvplugin_neato_layout.6.dylib
  /usr/local/lib/libgvplugin_quartz.6.dylib

Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
  /usr/local/lib/cairo-fdr.a
  /usr/local/lib/cairo-sphinx.a
  /usr/local/lib/libcairo-trace.a

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  python@2
  ghostscript
  3.7.1
  openjpeg
  3.7.2
  gnupg

Does env | grep github-myname output anything?

No results, even for bare github:

$ env | grep github-myname
$ env | grep github

Huh. Please run brew update --debug 2>&1 | tee update_dbg.log and post it here if it’s not too long, or on a site like pastebin.com or gist.github.com.

The full log is here: https://pastebin.com/G9BFUmYg

excerpt with error part
+ GITHUB_API_ETAG=ffb73d6ff3af0ba294bca890edaf00ee9e6cc6d0
+ GITHUB_API_ACCEPT=application/vnd.github.v3.sha
+ GITHUB_API_ENDPOINT=commits/master
++ curl -q --silent --max-time 3 --location --output /dev/null --write-out '%{http_code}' --dump-header /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/GITHUB_HEADERS --user-agent 'Homebrew/2.3.0-16-g0305001 (Macintosh; Intel Mac OS X 10.15.5) curl/7.64.1' --header 'Accept: application/vnd.github.v3.sha' --header 'If-None-Match: "ffb73d6ff3af0ba294bca890edaf00ee9e6cc6d0"' https://api.github.com/repos/Homebrew/homebrew-core/commits/master
+ declare PREFETCH_REVISION_HOMEBREW_HOMEBREW_SERVICES=0fee6732a3802d7be7adee5fa60c1f0f3d3c1062
+ [[ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services = \/\u\s\r\/\l\o\c\a\l\/\H\o\m\e\b\r\e\w ]]
+ [[ -z '' ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ wait
++ git config remote.origin.url
++ [[ -z /usr/local/bin/git ]]
++ /usr/local/bin/git config remote.origin.url
+ UPSTREAM_REPOSITORY_URL=https://github.com/Homebrew/homebrew-services
+ [[ https://github.com/Homebrew/homebrew-services = \h\t\t\p\s\:\/\/\g\i\t\h\u\b\.\c\o\m\/* ]]
+ UPSTREAM_REPOSITORY=Homebrew/homebrew-services
+ UPSTREAM_REPOSITORY=Homebrew/homebrew-services
+ [[ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services = \/\u\s\r\/\l\o\c\a\l\/\H\o\m\e\b\r\e\w ]]
++ git rev-parse refs/remotes/origin/master
++ [[ -z /usr/local/bin/git ]]
++ /usr/local/bin/git rev-parse refs/remotes/origin/master
+ GITHUB_API_ETAG=0fee6732a3802d7be7adee5fa60c1f0f3d3c1062
+ GITHUB_API_ACCEPT=application/vnd.github.v3.sha
+ GITHUB_API_ENDPOINT=commits/master
++ curl -q --silent --max-time 3 --location --output /dev/null --write-out '%{http_code}' --dump-header /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services/.git/GITHUB_HEADERS --user-agent 'Homebrew/2.3.0-16-g0305001 (Macintosh; Intel Mac OS X 10.15.5) curl/7.64.1' --header 'Accept: application/vnd.github.v3.sha' --header 'If-None-Match: "0fee6732a3802d7be7adee5fa60c1f0f3d3c1062"' https://api.github.com/repos/Homebrew/homebrew-services/commits/master
+ UPSTREAM_SHA_HTTP_CODE=200
+ [[ -f /usr/local/Homebrew/.git/FETCH_HEAD ]]
+ touch /usr/local/Homebrew/.git/FETCH_HEAD
+ [[ -z '' ]]
+ [[ 200 = \3\0\4 ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ git fetch --tags --force -q origin refs/heads/master:refs/remotes/origin/master
+ [[ -z /usr/local/bin/git ]]
+ /usr/local/bin/git fetch --tags --force -q origin refs/heads/master:refs/remotes/origin/master
+ UPSTREAM_SHA_HTTP_CODE=200
+ [[ -f /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/FETCH_HEAD ]]
+ touch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/FETCH_HEAD
+ [[ -z '' ]]
+ [[ 200 = \3\0\4 ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ git fetch --tags --force -q origin refs/heads/master:refs/remotes/origin/master
+ [[ -z /usr/local/bin/git ]]
+ /usr/local/bin/git fetch --tags --force -q origin refs/heads/master:refs/remotes/origin/master
+ UPSTREAM_SHA_HTTP_CODE=200
+ [[ -f /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services/.git/FETCH_HEAD ]]
+ touch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services/.git/FETCH_HEAD
+ [[ -z '' ]]
+ [[ 200 = \3\0\4 ]]
+ [[ -n '' ]]
+ [[ -n '' ]]
+ git fetch --tags --force -q origin refs/heads/master:refs/remotes/origin/master
+ [[ -z /usr/local/bin/git ]]
+ /usr/local/bin/git fetch --tags --force -q origin refs/heads/master:refs/remotes/origin/master
ssh: Could not resolve hostname github-myname: nodename nor servname provided, or not known
ssh: Could not resolve hostname github-myname: nodename nor servname provided, or not known
ssh: Could not resolve hostname github-myname: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
+ [[ 200 = \4\0\4 ]]
+ echo 'Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services failed!'
+ [[ 200 = \4\0\4 ]]
+ echo 'Fetching /usr/local/Homebrew failed!'
+ [[ 200 = \4\0\4 ]]
+ echo 'Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!'
+ trap - SIGINT
+ [[ -f /usr/local/Homebrew/.git/UPDATE_FAILED ]]
+ onoe
+ [[ -n '' ]]
+ [[ -t 2 ]]
+ echo -n 'Error: '
Error: + [[ 0 -eq 0 ]]
+ cat
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services failed!
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!
Fetching /usr/local/Homebrew failed!
+ rm -f /usr/local/Homebrew/.git/UPDATE_FAILED
+ export HOMEBREW_UPDATE_FAILED=1
+ HOMEBREW_UPDATE_FAILED=1

How did you get Homebrew to use github-myname in the first place, and what exactly did you do to direct it to github.com again?

The only thing I can recall is modifying ~/.ssh/config, I don’t think I ever did anything to Homebrew.

My guess is that when I first installed Homebrew it fetched github-myname somehow (doesn’t make sense, I know) and “cached” it somewhere and used this value to resolve the host from ~/.ssh/config, so now when I made changes in my ~/.ssh/config, Homebrew cannot find such a host there anymore. If I put github-myname back to my ~/.ssh/config, then Homebrew works fine again.

So if my guess it correct, I am now looking for a way to “tell” Homebrew to drop the cached github-myname and use github.com instead.

Just to be sure, what do these return?

  1. grep -rl github-myname $(brew --repo)
  2. env | grep GIT_
$ grep -rl github-myname $(brew --repo)
grep: /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/current: No such file or directory

and

$ env | grep GIT_

So, sadly, no results for both.

Just remembered one other possibility: git config -l | grep github-myname

If that returns an insteadOf line, there’s (almost certainly) your problem.

1 Like

Ooooooh, this is embarrassing. Yes, I had

[url "git@github-myname:"]
        insteadOf = https://github.com/

in my ~/.gitconfig. Removing that resolved the issue. So it was indeed my problem.

Thank you very much and sorry for wasting your time.

No worries, I just remembered using it myself to force-git: on my own repo URLs. At least it got me to look through my ancient .gitconfig…and clean out some stuff. :laughing:

1 Like