Closed orelmaliach closed 1 year ago
brew install kong ==> Fetching dependencies for kong/kong/kong: kong/kong/openresty@1.21.4.1 ==> Fetching kong/kong/openresty@1.21.4.1 ==> Downloading https://github.com/Kong/kong-build-tools/archive/4.33.22.tar.gz Already downloaded: /Users/mike/Library/Caches/Homebrew/downloads/8c26686f439ddceab9e9adaebceacf2b41b9a360a9c5d531755d9e9a05506837--kong-build-tools-4.33.22.tar.gz ==> Fetching kong/kong/kong ==> Downloading https://download.konghq.com/gateway-src/kong-3.1.1.tar.gz Already downloaded: /Users/mike/Library/Caches/Homebrew/downloads/24f9c15fcaa7dc824f8f88da62583c91f053625d4f80d25158cc18fee2fb56f9--kong-3.1.1.tar.gz ==> Installing kong from kong/kong ==> Installing dependencies for kong/kong/kong: kong/kong/openresty@1.21.4.1 ==> Installing kong/kong/kong dependency: kong/kong/openresty@1.21.4.1 /opt/homebrew/Library/Taps/kong/homebrew-kong/Formula/openresty@1.21.4.1.rb:58: warning: conflicting chdir during another chdir block ==> ./kong-ngx-build --prefix /opt/homebrew/Cellar/openresty@1.21.4.1/1.21.4.1 --openresty 1.21.4.1 --openssl 1.1.1q --luarocks 3.9.1 --pcre 8.45 --ssl-provider openssl --atc-router 1.0.1 --resty-events 0.1.3 --res Last 15 lines from /Users/mike/Library/Logs/Homebrew/openresty@1.21.4.1/01.kong-ngx-build: 2023-02-01 06:19:12 +0000
./kong-ngx-build --prefix /opt/homebrew/Cellar/openresty@1.21.4.1/1.21.4.1 --openresty 1.21.4.1 --openssl 1.1.1q --luarocks 3.9.1 --pcre 8.45 --ssl-provider openssl --atc-router 1.0.1 --resty-events 0.1.3 --resty-lmdb 1.0.0 --resty-websocket 0.3.0 -j 10
Do not report this issue to Homebrew/brew or Homebrew/core!
Same error
I've managed to bypass the issue with a naive fix to check if the directory exists and/or is a relative/absolute path. A formal fix would be appreciated.
I am also experiencing this error when running brew install --verbose kong
. @orelmaliach -- can you explain your workaround in more detail? I.e., how did you change the canon_path
function?
Also AFAICT, the openresty-build-tools
repo containing ./kong-ngx-build
gets pulled and extracted into a directory contained within private/tmp
. With that in mind, how did you make changes that were reflected when you called brew install kong
or brew install openresty@1.21.4.1
?
Several more of my colleagues faced the exact same issue (all of them running with Mac OS 13.1, not necessarily M1, though). My workaround fixed the problem for all of them, so I decided to share it.
To work around the problem(s), you need to perform the following:
brew install kong/kong/kong --debug
vi ./kong-ngx-build
canon_path() {
if realpath -m -- $1 2>/dev/null >&2; then
realpath -m -- $1
elif [[ -f $1 ]]; then
readlink -f -- $1
elif [[ $1 = /* ]]; then
echo $1
else
echo $PWD/$1
fi
}
exit 0
IF you encounter another issue later running patch
command, it's because of a different issue: https://github.com/Kong/homebrew-kong/issues/209
You can ignore it (option 2), but once the installation finishes successfully, you will need to run the following:
vi $(which kong)
#!/usr/bin/env resty
setmetatable(_G, nil)
pcall(require, "luarocks.loader")
package.cpath = (os.getenv("KONG_LUA_CPATH_OVERRIDE") or "") .. "/opt/homebrew/lib/lua/5.1/?.so;" .. package.cpath
package.path = (os.getenv("KONG_LUA_PATH_OVERRIDE") or "") .. "./?.lua;./?/init.lua;" .. "/opt/homebrew/share/lua/5.1/?.lua;/opt/homebrew/share/lua/5.1/?/init.lua;" .. package.path
require("kong.cmd.init")(arg)
If this fix worked for you, please give a thumbs up, or reply with any additional/different steps you needed to make.
kong-build-tools is no longer maintained, we are updating our docs on building Kong from source and also update homebrew tap. please hold for updates : )
I'm trying to run
brew install kong/kong/kong
(latest version is 3.1.1 at this time). It installs successfully libyaml, coreutils, gmp, pkg-config, rust, openssl@1.1, but fails when installing openresty@1.21.4.1.I'm running on an M1 Mac (arm64 arch), running OS13.1. I asked my colleague to try installing the same (using M1, with Monterey OS), and kong was installed successfully for him.
There's a warning during the installation attempt (I don't think it's related since my colleague had it as well): /opt/homebrew/Library/Taps/kong/homebrew-kong/Formula/openresty@1.21.4.1.rb:58: warning: conflicting chdir during another chdir block
I've already tried:
Error: openresty@1.21.4.1 is already installed from openresty/brew! Please
brew uninstall openresty@1.21.4.1
first."None of these worked.
In terminal, this is the output:
➜ ~ brew install openresty@1.21.4.1 ==> Fetching kong/kong/openresty@1.21.4.1 ==> Downloading https://github.com/Kong/kong-build-tools/archive/4.33.22.tar.gz Already downloaded: /Users/oelmaliach/Library/Caches/Homebrew/downloads/8c26686f439ddceab9e9adaebceacf2b41b9a360a9c5d531755d9e9a05506837--kong-build-tools-4.33.22.tar.gz ==> Installing openresty@1.21.4.1 from kong/kong /opt/homebrew/Library/Taps/kong/homebrew-kong/Formula/openresty@1.21.4.1.rb:58: warning: conflicting chdir during another chdir block ==> ./kong-ngx-build --prefix /opt/homebrew/Cellar/openresty@1.21.4.1/1.21.4.1 --openresty 1.21.4.1 --openssl 1.1.1q --luarocks 3.9.1 --pcre 8.45 --ssl-provider openssl --atc-router 1.0.1 --resty-events 0.1.3 --resty-lmdb 1.0.0 --resty-websocket 0 Last 15 lines from /Users/oelmaliach/Library/Logs/Homebrew/openresty@1.21.4.1/01.kong-ngx-build: 2023-01-15 16:34:17 +0000
./kong-ngx-build --prefix /opt/homebrew/Cellar/openresty@1.21.4.1/1.21.4.1 --openresty 1.21.4.1 --openssl 1.1.1q --luarocks 3.9.1 --pcre 8.45 --ssl-provider openssl --atc-router 1.0.1 --resty-events 0.1.3 --resty-lmdb 1.0.0 --resty-websocket 0.3.0 -j 10
Do not report this issue to Homebrew/brew or Homebrew/core!
There was no further information in the log file: https://pastebin.com/z4gWxAHq
After further investigation, and running
brew install openresty@1.21.4.1 --debug --verbose
, I managed to isolate the issue to this script that fails during invocation of canon_path function, on multiple occasions. One example was with the following line:DOWNLOAD_CACHE=`canon_path $DOWNLOAD_CACHE`
It failed due to the directory passed as argument (work
) not existing, making bothrealpath
andreadlink
fail.I've managed to bypass the issue with a naive fix to check if the directory exists and/or is a relative/absolute path. A formal fix would be appreciated.