Kong/homebrew-kong

Error: Failed installing dependency: https://luarocks.org/lyaml-6.2.7-1.src.rock

vitor-l opened this issue ยท 24 comments

Hello! I'm trying to install kong in my macOS Big Sur (Version 11.5).

Input in my terminal:

brew tap kong/kong

Output: OK!

Input in my terminal:

brew install kong

Output:

Error: Failed installing dependency: https://luarocks.org/lyaml-6.2.7-1.src.rock - Could not find library file for YAML
  No file libyaml.a in /usr/local/lib
  No file libyaml.dylib in /usr/local/lib
  No file matching libyaml.so.* in /usr/local/lib
  No file libyaml.a in /usr/lib
  No file libyaml.dylib in /usr/lib
  No file matching libyaml.so.* in /usr/lib
  No file libyaml.a in /lib
  No file libyaml.dylib in /lib
  No file matching libyaml.so.* in /lib
You may have to install YAML in your system and/or pass YAML_DIR or YAML_LIBDIR to the luarocks command.
Example: luarocks install lyaml YAML_DIR=/usr/local

That might have been a temporary problem in the luarocks server. Please retry.

I tried yesterday and It did not work...

@vitor-l I just merged a fix (#176) so the formula has changed. Please try:

brew uninstall openresty
brew uninstall kong/kong/openresty
brew untap kong/kong
brew tap kong/kong
brew install kong

Nope... still an error.

kong 2.5.0-0 depends on lyaml 6.2.7 (not installed)
Installing https://luarocks.org/lyaml-6.2.7-1.src.rock

Error: Failed installing dependency: https://luarocks.org/lyaml-6.2.7-1.src.rock - Could not find library file for YAML
  No file libyaml.a in /usr/local/lib
  No file libyaml.dylib in /usr/local/lib
  No file matching libyaml.so.* in /usr/local/lib
  No file libyaml.a in /usr/lib
  No file libyaml.dylib in /usr/lib
  No file matching libyaml.so.* in /usr/lib
  No file libyaml.a in /lib
  No file libyaml.dylib in /lib
  No file matching libyaml.so.* in /lib
You may have to install YAML in your system and/or pass YAML_DIR or YAML_LIBDIR to the luarocks command.
Example: luarocks install lyaml YAML_DIR=/usr/local

Do not report this issue to Homebrew/brew or Homebrew/core!

Nope... still an error.

kong 2.5.0-0 depends on lyaml 6.2.7 (not installed)
Installing https://luarocks.org/lyaml-6.2.7-1.src.rock

Error: Failed installing dependency: https://luarocks.org/lyaml-6.2.7-1.src.rock - Could not find library file for YAML
  No file libyaml.a in /usr/local/lib
  No file libyaml.dylib in /usr/local/lib
  No file matching libyaml.so.* in /usr/local/lib
  No file libyaml.a in /usr/lib
  No file libyaml.dylib in /usr/lib
  No file matching libyaml.so.* in /usr/lib
  No file libyaml.a in /lib
  No file libyaml.dylib in /lib
  No file matching libyaml.so.* in /lib
You may have to install YAML in your system and/or pass YAML_DIR or YAML_LIBDIR to the luarocks command.
Example: luarocks install lyaml YAML_DIR=/usr/local

Do not report this issue to Homebrew/brew or Homebrew/core!

1.luarocks install lyaml

Error: Could not find library file for YAML
  No file libyaml.a in /usr/local/lib
  No file libyaml.dylib in /usr/local/lib
  No file matching libyaml.so.* in /usr/local/lib

2.brew info libyaml
/opt/homebrew/Cellar/libyaml/0.2.5

3.luarocks install lyaml YAML_LIBDIR=/opt/homebrew/Cellar/libyaml/0.2.5/lib/ YAML_INCDIR=/opt/homebrew/Cellar/libyaml/0.2.5/include/
It looks like sucess:lyaml 6.2.7-1 is now installed in /opt/homebrew/Cellar/openresty@1.19.3.2/1.19.3.2/luarocks

4.brew install kong

it still an error:
No file libyaml.a in /usr/local/lib
  No file libyaml.dylib in /usr/local/lib
  No file matching libyaml.so.* in /usr/local/lib
  No file libyaml.a in /usr/lib
  No file libyaml.dylib in /usr/lib
  No file matching libyaml.so.* in /usr/lib
  No file libyaml.a in /lib
  No file libyaml.dylib in /lib
  No file matching libyaml.so.* in /lib

5.ln -s /opt/homebrew/Cellar/libyaml/0.2.5/lib/* /usr/local/lib
brew install kong

brew install kong

==> Installing kong from kong/kong
==> Downloading https://download.konghq.com/gateway-src/kong-2.5.0.tar.gz
Already downloaded: /Users/wuyachao/Library/Caches/Homebrew/downloads/2f8ba8914e27f26f25f76ebd16a3453474274690b35bee36621f0cde3a373335--kong-2.5.0.tar.gz
==> Patching
==> /opt/homebrew/opt/openresty@1.19.3.2/luarocks/bin/luarocks --tree=/opt/homebrew/Cellar/kong/2.5.0 make CRYPTO_DIR=/opt/homebrew/opt/openresty@1.19.3.2/openssl OPENS
๐Ÿบ  /opt/homebrew/Cellar/kong/2.5.0: 1,221 files, 10.0MB, built in 1 minute 30 seconds

I'm able to install the forumla without problem, and libyaml.dylib seems to be already in my /usr/local/lib.

ln -s /opt/homebrew/Cellar/libyaml/0.2.5/lib/* /usr/local/lib

homebrew should automatically link libyaml to /usr/loca/lib as long as the forumla is not "keg-only". I'm not sure
how/what will result in a broken install state for libyaml.
Could you verify the following command:

ls /usr/local/lib | grep yaml

Is it returns empty? If so, could you try brew uninstall --ignore-dependencies libyaml and brew install libyaml and
share the output of ls /usr/local/lib | grep yaml command again?

Hi, @fffonion!

I have tried the command before and after installing libyaml. The output of both is empty.

Thank for verifying that for me @vitor-l . Could you do a brew info libyaml and share the output?
Also does brew link libyaml change the output of ls /usr/local/lib | grep yaml?

Output for brew info libyaml:

libyaml: stable 0.2.5 (bottled)
YAML Parser
https://github.com/yaml/libyaml
/opt/homebrew/Cellar/libyaml/0.2.5 (10 files, 369.9KB) *
  Poured from bottle on 2021-08-27 at 15:02:02
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libyaml.rb
License: MIT
==> Dependencies
Build: autoconf โœ˜, automake โœ˜, libtool โœ˜
==> Analytics
install: 72,239 (30 days), 218,109 (90 days), 1,033,827 (365 days)
install-on-request: 13,640 (30 days), 43,149 (90 days), 219,177 (365 days)
build-error: 0 (30 days)

When I do brew link libyaml:

Warning: Already linked: /opt/homebrew/Cellar/libyaml/0.2.5
To relink, run:
  brew unlink libyaml && brew link libyaml

After unlink and linking again:

Unlinking /opt/homebrew/Cellar/libyaml/0.2.5... 5 symlinks removed.
Linking /opt/homebrew/Cellar/libyaml/0.2.5... 5 symlinks created.

Output for ls /usr/local/lib | grep yaml is still empty.

@vitor-l Thanks, could you share the output of brew --version and are you using mac with Apple chip (M1)? Seems in M1 homebrew uses a different location for linking.

If so, could you try the fix/test-opt_lib branch?

git clone https://github.com/Kong/homebrew-kong -b fix/test-opt_lib
cd homebrew-kong/Formula
brew install ./kong.rb

(Ref: Homebrew/discussions#664, link: Kong/kong#7705)

Output for brew --version:

Homebrew 3.2.9
Homebrew/homebrew-core (git revision 97ff7d3acb; last commit 2021-08-27)
Homebrew/homebrew-cask (git revision 606ed52390; last commit 2021-08-27)

Yes, Im using mac with Apple chip. So, the output for brew install ./kong.rb`:

Error: Failed to load cask: ./kong.rb
Cask 'kong' is unreadable: wrong constant name #<Class:0x000000012e89e8b8>
Warning: Treating ./kong.rb as a formula.
==> Downloading https://download.konghq.com/gateway-src/kong-2.5.0.tar.gz
Already downloaded: /Users/vitorlgs/Library/Caches/Homebrew/downloads/2f8ba8914e27f26f25f76ebd16a3453474274690b35bee36621f0cde3a373335--kong-2.5.0.tar.gz
==> Patching
==> /opt/homebrew/opt/openresty@1.19.3.2/luarocks/bin/luarocks --tree=/opt/homebrew/Cell
Last 15 lines from /Users/vitorlgs/Library/Logs/Homebrew/kong/01.luarocks:
kong 2.5.0-0 depends on lyaml 6.2.7 (not installed)
Installing https://luarocks.org/lyaml-6.2.7-1.src.rock

Error: Failed installing dependency: https://luarocks.org/lyaml-6.2.7-1.src.rock - Could not find library file for YAML
  No file libyaml.a in /usr/local/lib
  No file libyaml.dylib in /usr/local/lib
  No file matching libyaml.so.* in /usr/local/lib
  No file libyaml.a in /usr/lib
  No file libyaml.dylib in /usr/lib
  No file matching libyaml.so.* in /usr/lib
  No file libyaml.a in /lib
  No file libyaml.dylib in /lib
  No file matching libyaml.so.* in /lib
You may have to install YAML in your system and/or pass YAML_DIR or YAML_LIBDIR to the luarocks command.
Example: luarocks install lyaml YAML_DIR=/usr/local

Traceback:

	26: from /opt/homebrew/Library/Homebrew/build.rb:229:in `<main>'
	25: from /opt/homebrew/Library/Homebrew/build.rb:133:in `install'
	24: from /opt/homebrew/Library/Homebrew/utils.rb:550:in `with_env'
	23: from /opt/homebrew/Library/Homebrew/build.rb:138:in `block in install'
	22: from /opt/homebrew/Library/Homebrew/formula.rb:1275:in `brew'
	21: from /opt/homebrew/Library/Homebrew/formula.rb:2434:in `stage'
	20: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/forwardable.rb:230:in `stage'
	19: from /opt/homebrew/Library/Homebrew/resource.rb:91:in `stage'
	18: from /opt/homebrew/Library/Homebrew/resource.rb:116:in `unpack'
	17: from /opt/homebrew/Library/Homebrew/resource.rb:199:in `mktemp'
	16: from /opt/homebrew/Library/Homebrew/mktemp.rb:63:in `run'
	15: from /opt/homebrew/Library/Homebrew/mktemp.rb:63:in `chdir'
	14: from /opt/homebrew/Library/Homebrew/mktemp.rb:63:in `block in run'
	13: from /opt/homebrew/Library/Homebrew/resource.rb:117:in `block in unpack'
	12: from /opt/homebrew/Library/Homebrew/download_strategy.rb:102:in `stage'
	11: from /opt/homebrew/Library/Homebrew/download_strategy.rb:115:in `chdir'
	10: from /opt/homebrew/Library/Homebrew/download_strategy.rb:115:in `chdir'
	 9: from /opt/homebrew/Library/Homebrew/resource.rb:121:in `block (2 levels) in unpack'
	 8: from /opt/homebrew/Library/Homebrew/formula.rb:2454:in `block in stage'
	 7: from /opt/homebrew/Library/Homebrew/utils.rb:550:in `with_env'
	 6: from /opt/homebrew/Library/Homebrew/formula.rb:2455:in `block (2 levels) in stage'
	 5: from /opt/homebrew/Library/Homebrew/formula.rb:1282:in `block in brew'
	 4: from /opt/homebrew/Library/Homebrew/build.rb:178:in `block (2 levels) in install'
	 3: from /Users/vitorlgs/Projects/kong/homebrew-kong/Formula/kong.rb:31:in `install'
	 2: from /opt/homebrew/Library/Homebrew/formula.rb:2225:in `system'
	 1: from /opt/homebrew/Library/Homebrew/formula.rb:2225:in `open'
/opt/homebrew/Library/Homebrew/formula.rb:2289:in `block in system': Failed executing: /opt/homebrew/opt/openresty@1.19.3.2/luarocks/bin/luarocks --tree=/opt/homebrew/Cellar/kong/2.5.0 make CRYPTO_DIR=/opt/homebrew/opt/openresty@1.19.3.2/openssl OPENSSL_DIR=/opt/homebrew/opt/openresty@1.19.3.2/openssl (BuildError)
	5: from /opt/homebrew/Library/Homebrew/brew.rb:162:in `<main>'
	4: from /opt/homebrew/Library/Homebrew/brew.rb:174:in `rescue in <main>'
	3: from /opt/homebrew/Library/Homebrew/exceptions.rb:509:in `dump'
	2: from /opt/homebrew/Library/Homebrew/exceptions.rb:455:in `issues'
	1: from /opt/homebrew/Library/Homebrew/exceptions.rb:459:in `fetch_issues'
/opt/homebrew/Library/Homebrew/utils/github.rb:60:in `issues_for_formula': undefined method `full_name' for nil:NilClass (NoMethodError)

Thank you @vitor-l . Let me figure out what to do next ๐Ÿค”, may need to test on a M1 mac .

I made another attempt on the fix/test-opt_lib, could you test one more time @vitor-l ?

Hello @fffonion, sorry for the late response. So I did a git fetch --all and git pull origin fix/test-opt_lib. At Formula folder, I executed brew install ./kong.rb.

Output for brew install ./kong.rb:

Error: Failed to load cask: ./kong.rb
Cask 'kong' is unreadable: wrong constant name #<Class:0x000000014b1b66c8>
Warning: Treating ./kong.rb as a formula.
==> Downloading https://download.konghq.com/gateway-src/kong-2.5.0.tar.gz
Already downloaded: /Users/vitorlgs/Library/Caches/Homebrew/downloads/2f8ba8914e27f26f25f76ebd16a3453474274690b35bee36621f0cde3a373335--kong-2.5.0.tar.gz
==> Patching
==> /opt/homebrew/opt/openresty@1.19.3.2/luarocks/bin/luarocks --tree=/opt/homebrew/Cellar/kong/2.5.0 make CRYPTO_DIR=/opt/homebrew/opt/openresty@1.19.3.2/openssl OPENSSL_DIR=/
๐Ÿบ  /opt/homebrew/Cellar/kong/2.5.0: 1,221 files, 10.0MB, built in 1 minute 41 seconds
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /Users/vitorlgs/Library/Caches/Homebrew/c-ares--1.17.1... (164.8KB)
Removing: /Users/vitorlgs/Library/Caches/Homebrew/cmake--3.21.1... (17MB)
Removing: /Users/vitorlgs/Library/Caches/Homebrew/glib--2.68.3... (6.5MB)
Removing: /Users/vitorlgs/Library/Caches/Homebrew/m4--1.4.18... (228.4KB)
Removing: /Users/vitorlgs/Library/Caches/Homebrew/mutagen-beta--0.12.0-beta4.tar.gz... (78.4MB)
Removing: /Users/vitorlgs/Library/Caches/Homebrew/node--16.6.1... (12.5MB)
Removing: /Users/vitorlgs/Library/Caches/Homebrew/openssl@1.1--1.1.1k... (5.2MB)
Removing: /Users/vitorlgs/Library/Caches/Homebrew/webp--1.2.0... (745.8KB)
Removing: /Users/vitorlgs/Library/Logs/Homebrew/coreutils... (64B)
Removing: /Users/vitorlgs/Library/Logs/Homebrew/wxmac... (64B)
Removing: /Users/vitorlgs/Library/Logs/Homebrew/elixir... (64B)
Removing: /Users/vitorlgs/Library/Logs/Homebrew/libyaml... (64B)
Removing: /Users/vitorlgs/Library/Logs/Homebrew/erlang... (64B)
Removing: /Users/vitorlgs/Library/Logs/Homebrew/luarocks... (64B)
Removing: /Users/vitorlgs/Library/Logs/Homebrew/lua... (64B)
Removing: /Users/vitorlgs/Library/Logs/Homebrew/openresty@1.19.3.1... (4 files, 4.9MB)

Output for brew --version:

Homebrew 3.2.9
Homebrew/homebrew-core (git revision fa395c6627; last commit 2021-08-27)
Homebrew/homebrew-cask (git revision 606ed52390; last commit 2021-08-27)

Output for brew info libyaml:

libyaml: stable 0.2.5 (bottled)
YAML Parser
https://github.com/yaml/libyaml
/opt/homebrew/Cellar/libyaml/0.2.5 (10 files, 369.9KB) *
  Poured from bottle on 2021-08-27 at 15:02:02
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libyaml.rb
License: MIT
==> Dependencies
Build: autoconf โœ˜, automake โœ˜, libtool โœ˜
==> Analytics
install: 73,270 (30 days), 218,603 (90 days), 1,026,825 (365 days)
install-on-request: 13,656 (30 days), 42,768 (90 days), 217,333 (365 days)
build-error: 0 (30 days)

Output for ls /usr/local/lib | grep yaml is empty

๐Ÿบ  /opt/homebrew/Cellar/kong/2.5.0: 1,221 files, 10.0MB, built in 1 minute 41 seconds

Looks like the formula built successfully, which looks good. Are you able to use Kong after it's being installed? @vitor-l

I did not have the change to try, but as you said, @fffonion, the installation was ok. I did not test because I dropped the project using Kong... But, if I have any problems, I'll let you know. Thanks for the help and sorry for the late response.

Hello, @fffonion!

When I run kong config init, I get this output:

env: resty: No such file or directory

I think that this is not supposed to happen...

@vitor-l That might be a PATH issue, M1 version of homebrew has its bin path as /opt/homebrew/bin. Do you have that
path in your shell's PATH environment variable? That should be a generic configuration on M1 not just Kong, basically
all other binaries installed by homebrew would be inaccessible without that config.

@fffonion, output for echo $PATH:

/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin

It seems like opt/homebrew/bin is there

@vitor-l You can check it by running echo $PATH in your shell.
And if you don't remember configuring so, then
you haven't configured it : ) The path doesn't come by default from macOS. You can use Homebrew/discussions#545 as a guide.

By reading the guide I think you can even install a x64 version of homebrew and install x64 verion of Kong if
you find configuring the ARM version too complex. I'm not sure why homebrew decided to make the installation
that non-automated.

@vitor-l Hmm I see ๐Ÿค” . Could you check if resty is in /opt/homebrew/bin?

ls /opt/homebrew/bin | grep resty

@fffonion, resty is not there. The output is empty.

@vitor-l Okay, that might be the issue. But I didn't see why it's not there per https://github.com/Kong/homebrew-kong/blob/master/Formula/openresty%401.19.3.2.rb#L51. Are you able to use any others like nginx or luarocks?
Did you observe any information when installing Kong that says something like "is not linked"? Could you try
brew link kong ๐Ÿค” ?

@fffonion, I did not observe anything like that. It seems that kong was already linked.

โฏ brew link kong
Warning: Already linked: /opt/homebrew/Cellar/kong/2.5.1
To relink, run:
  brew unlink kong && brew link kong
โฏ brew unlink kong && brew link kong
Unlinking /opt/homebrew/Cellar/kong/2.5.1... 671 symlinks removed.
Linking /opt/homebrew/Cellar/kong/2.5.1... 671 symlinks created.