Genivia / ugrep

NEW ugrep 6.5: a more powerful, ultra fast, user-friendly, compatible grep. Includes a TUI, Google-like Boolean search with AND/OR/NOT, fuzzy search, hexdumps, searches (nested) archives (zip, 7z, tar, pax, cpio), compressed files (gz, Z, bz2, lzma, xz, lz4, zstd, brotli), pdfs, docs, and more
https://ugrep.com
BSD 3-Clause "New" or "Revised" License
2.56k stars 109 forks source link

Ugrep search throws error -z option not available in new Homebrew ugrep v5.1.2 #380

Closed ciscohack closed 4 months ago

ciscohack commented 4 months ago

Hello Expert,

I did ugrep upgrade to 5.1.2 and while search getting the below error due to which not able to search.. it was working few min back before upgrade

image
ciscohack commented 4 months ago

I have ugrep config file with decompress search option enabled ..it seems broken code to me

image
genivia-inc commented 4 months ago

What does ugrep --version say? It looks like it may have been built without libz linkage. Without libz it won't decompress anything. Since libz is available pretty much anywhere, I don't know what caused this. Did you built ugrep with ./build.sh?

genivia-inc commented 4 months ago

The CI test of 5.1.2 passes and includes all compression libraries, like all machines we test on our end before releasing an update:

image
ciscohack commented 4 months ago

The CI test of 5.1.2 passes and includes all compression libraries, like all machines we test on our end before releasing an update:

image

Thanks for quick response then why i am having mentioned error ... it wasn't there one release before with same config

genivia-inc commented 4 months ago

The error only occurs when ugrep was not built with libz, there is no other cause:

#ifndef HAVE_LIBZ
  // -z: but we don't have libz
  if (flag_decompress)
    usage("option -z is not available in this build configuration of ugrep");
#endif

The configure scripts have only minor changes and some restructuring, one change is to use pkg-config to detect libraries. That is a pretty standard way these days to detect libraries. If the libraries cannot be found at the usual locations, then it is still possible to specify custom locations with ./build.sh, which calls ./configure.

When you run ./build.sh it should show something like this:

checking for libpcre2-8... yes
checking for zlib... yes
checking for library containing BZ2_bzRead... -lbz2
checking for bzlib.h... yes
checking for liblzma... yes
checking for liblz4... yes
checking for libzstd... yes
checking for libbrotlidec... yes
checking for --disable-7zip... no

The second line in the above sets HAVE_LIBZ to 1 in config.h. Then make produces ugrep linked with libz and the error is not there, for sure.

ciscohack commented 4 months ago

The error only occurs when ugrep was not built with libz, there is no other cause:

#ifndef HAVE_LIBZ
  // -z: but we don't have libz
  if (flag_decompress)
    usage("option -z is not available in this build configuration of ugrep");
#endif

The configure scripts have only minor changes and some restructuring, one change is to use pkg-config to detect libraries. That is a pretty standard way these days to detect libraries. If the libraries cannot be found at the usual locations, then it is still possible to specify custom locations with ./build.sh, which calls ./configure.

When you run ./build.sh it should show something like this:

checking for libpcre2-8... yes
checking for zlib... yes
checking for library containing BZ2_bzRead... -lbz2
checking for bzlib.h... yes
checking for liblzma... yes
checking for liblz4... yes
checking for libzstd... yes
checking for libbrotlidec... yes
checking for --disable-7zip... no

The second line in the above sets HAVE_LIBZ to 1 in config.h. Then make produces ugrep linked with libz and the error is not there, for sure.

I installed via brew ..should I reinstall the tool ..will it solve the problem

ciscohack commented 4 months ago

is there any command to re-generate .ugrep config file .. I tried ug --config option but not working for me ..can you please help me with exact command syntax to generate new .ugrep file

ciscohack commented 4 months ago

@genivia-inc I did a reinstall but the same error and ./build.sh seems I will get only when I close and recompile but as I said I am using brew to install on my macOS 14.3... request you to please me to get rid of this problem..

or help me to install old version if we can't fix this issue

ciscohack commented 4 months ago

@genivia-inc Here is the code fix missing in 5.1.2 and causing a broken -z option... request you please fix and ugrep is now missing major feature I used most -z option

https://github.com/Genivia/ugrep-indexer/releases/tag/v0.9.6

genivia-inc commented 4 months ago

Looks like brew install is broken?

$ ugrep --version
ugrep 5.1.2 aarch64-apple-darwin21.6.0 +neon/AArch64

shows no -P and -z!

ciscohack commented 4 months ago

Looks like brew install is broken?

$ ugrep --version
ugrep 5.1.2 aarch64-apple-darwin21.6.0 +neon/AArch64

shows no -P and -z!

yes look like brew install is broken for sure -z and --decompress option is I tried and broken and most likely other options could also have problem..

here is my output

ugrep --version
ugrep 5.1.2 aarch64-apple-darwin23.4.0 +neon/AArch64 License: BSD-3-Clause; ugrep user manual: https://ugrep.com Written by Robert van Engelen and others: https://github.com/Genivia/ugrep Ugrep utilizes the RE/flex regex library: https://github.com/Genivia/RE-flex

genivia-inc commented 4 months ago

I will revert the configure script to the one I've used with 5.1.1 that worked for Homebrew, but with a few minor changes to include additions. Then update 5.1.3 should work for homebrew again as it had worked before.

ciscohack commented 4 months ago

I will revert the configure script to the one I've used with 5.1.1 that worked for Homebrew, but with a few minor changes to include additions. Then update 5.1.3 should work for homebrew again as it had worked before.

thank you so much

genivia-inc commented 4 months ago

I've committed and released 5.1.3 that reverts the configure script changes (those where suggested by others #339, I should have known better) that affect compression libraries and PCRE2 detection.

It may take a couple of hours for Homebrew ugrep to update to 5.1.3.

Hopefully the problem is fixed. If not, I will need to investigate and go through the Homebrew formula instructions and verify things to figure out what goes wrong. That will take much more time. So keep fingers crossed!

genivia-inc commented 4 months ago

I checked Homebrew ugrep 5.1.3 and it looks like it picked up the proper library dependences again:

$ brew install ugrep
...
==> Downloading https://ghcr.io/v2/homebrew/core/ugrep/manifests/5.1.3
...
$ /opt/homebrew/bin/ugrep --version
ugrep 5.1.3 aarch64-apple-darwin21.6.0 +neon/AArch64; -P:pcre2jit; -z:zlib,bzip2,lzma,lz4,zstd,brotli
ciscohack commented 4 months ago

@genivia-inc you are awesome my friend working fine now thanks