others-How to solve No such file or directory exception when using brew to install apps on macos

1. Purpose

In this post, I would demo how to solve No such file or directory exception when trying to install app by brew install:

➜  ~ brew install todoist
Updating Homebrew...
^C

==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/go-1.17.1.catalina.bottle.tar.gz

#=#=#
curl: (22) The requested URL returned error: 404
Warning: Bottle missing, falling back to the default domain...
==> Downloading https://ghcr.io/v2/homebrew/core/go/manifests/1.17.1
Already downloaded: /Users/bswen/Library/Caches/Homebrew/downloads/271518811dff5d3265f455a0cd7d259dcc09a46bc1e9735e0fc9a372e7bc542f--go-1.17.1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/go/blobs/sha256:15f1890939c34f3eeb841c09c6b74c23c43450337d50a3f0963493a3a861b7f9
Already downloaded: /Users/bswen/Library/Caches/Homebrew/downloads/599413457184d5a77fb476a4db7bdcd4d5292855c581a47dbc621360c175bdbf--go--1.17.1.catalina.bottle.tar.gz
==> Downloading https://github.com/sachaos/todoist/archive/v0.15.0.tar.gz
Already downloaded: /Users/bswen/Library/Caches/Homebrew/downloads/ec57aed732fbf580517f78b7ffdac890a3803d0eb1c880b732f0d00e91d7ac78--todoist-0.15.0.tar.gz
==> Installing todoist from sachaos/todoist
==> Installing dependencies for sachaos/todoist/todoist: go
==> Installing sachaos/todoist/todoist dependency: go
==> Pouring go-1.17.1.catalina.bottle.tar.gz
Error: No such file or directory @ rb_sysopen - /Users/bswen/Library/Caches/Homebrew/downloads/75b265788a94bd1340dc7dd08617b2168a20d861c310ab7a31d5904aa5aa62bd--go-1.17.1.catalina.bottle.tar.gz
➜  ~

The core error message is:

==> Pouring go-1.17.1.catalina.bottle.tar.gz
Error: No such file or directory @ rb_sysopen - /Users/bswen/Library/Caches/Homebrew/downloads/75b265788a94bd1340dc7dd08617b2168a20d861c310ab7a31d5904aa5aa62bd--go-1.17.1.catalina.bottle.tar.gz

2. What is a Bottle in HomeBrew?

Bottles mean ‘Binary Packages’ in HomeBrew.

According to this document:

Bottles are produced by installing a formula with brew install --build-bottle <formula> and then bottling it with brew bottle <formula>. This outputs the bottle DSL which should be inserted into the formula file.

If a bottle is available and usable it will be downloaded and poured automatically when you brew install <formula>. If you wish to disable this you can do so by specifying --build-from-source.

3. How to solve this problem?

According to the above process, I think I should install the golang 1.17 by myself. So I open my browser and goto ` https://golang.org/dl/ ` , download the golang 1.17 macos package and install it.

If you are using macbook pro and you can download go 1.17 directory as below:

https://golang.org/dl/go1.17.2.darwin-amd64.pkg

After install , I verify as follows:

➜  ~ go version
go version go1.17.1 darwin/amd64

then I install the app again:

➜  ~ brew install todoist
Updating Homebrew...
==> Downloading https://github.com/sachaos/todoist/archive/v0.15.0.tar.gz
Already downloaded: /Users/bswen/Library/Caches/Homebrew/downloads/ec57aed732fbf580517f78b7ffdac890a3803d0eb1c880b732f0d00e91d7ac78--todoist-0.15.0.tar.gz
==> Installing todoist from sachaos/todoist
==> go build -o /usr/local/Cellar/todoist/0.15.0/bin/todoist
==> Caveats
zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/todoist/0.15.0: 7 files, 9.5MB, built in 40 seconds
➜  ~ todoist
Input API Token:
➜  ~

4. Summary

In this post, I demonstrated how to solve the No such file or directory error when using homebrew to install todoist cli app, the key point is to know the bottleneck of the installation , solve it and you are done.