Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homebrew not working #6

Closed
anhdle14 opened this issue Nov 25, 2021 · 15 comments
Closed

Homebrew not working #6

anhdle14 opened this issue Nov 25, 2021 · 15 comments
Labels
bug Something isn't working

Comments

@anhdle14
Copy link

❯ brew tap "rhysd/hgrep" "https://github.com/rhysd/hgrep"
brew install hgrep
==> Downloading https://github.com/rhysd/hgrep/releases/download/v0.2.1/hgrep-v0.2.1-x86_64-apple-darwin.zip
Already downloaded: /Users/$USER/Library/Caches/Homebrew/downloads/712103ea480f4147dde712234225835a35bc2a2213180120913b81329051bd47--hgrep-v0.2.1-x86_64-apple-darwin.zip
==> Installing hgrep from rhysd/hgrep
Error: Failure while executing; `/Users/$USER/homebrew/Cellar/hgrep/0.2.1/bin/hgrep --generate-completion-script zsh` was terminated by uncaught signal ABRT. Here's the output:
❯ /Users/$USER/homebrew/Cellar/hgrep/0.2.1/bin/hgrep --generate-completion-script zsh
zsh: no such file or directory: /Users/$USER/homebrew/Cellar/hgrep/0.2.1/bin/hgrep

Don't think it is related to OS, but if you need I will share.

@rhysd rhysd added the bug Something isn't working label Nov 25, 2021
@rhysd
Copy link
Owner

rhysd commented Nov 25, 2021

Thank you for reporting this. I'll take a look.

@rhysd
Copy link
Owner

rhysd commented Nov 25, 2021

I guess this is related to where Homebrew is installed. I tried brew install hgrep now and it finished successfully. I installed Hombrew in system global (/usr/local/Cella) but you installed it in user local. It may cause this issue.

@rhysd rhysd closed this as completed in 04a2c4c Nov 25, 2021
@rhysd
Copy link
Owner

rhysd commented Nov 25, 2021

I added workaround for this at 04a2c4c. Would you try brew up && brew install hgrep again?

@anhdle14
Copy link
Author

❯ brew up && brew install hgrep
Updated 2 taps (rhysd/hgrep and homebrew/core).
==> Updated Formulae
git ✔                                                     git-credential-libsecret                                  git-gui                                                   git-svn                                                   halide
...
You have 20 outdated formulae and 2 outdated casks installed.
You can upgrade them with brew upgrade
or list them with brew outdated.
==> Downloading https://github.com/rhysd/hgrep/releases/download/v0.2.1/hgrep-v0.2.1-x86_64-apple-darwin.zip
Already downloaded: /Users/anhdle14/Library/Caches/Homebrew/downloads/712103ea480f4147dde712234225835a35bc2a2213180120913b81329051bd47--hgrep-v0.2.1-x86_64-apple-darwin.zip
==> Installing hgrep from rhysd/hgrep
Error: Failure while executing; `/Users/anhdle14/homebrew/Cellar/hgrep/0.2.1/bin/hgrep --generate-completion-script zsh` was terminated by uncaught signal ABRT. Here's the output:
❯ /Users/anhdle14/homebrew/Cellar/hgrep/0.2.1/bin/hgrep --generate-completion-script zsh
zsh: no such file or directory: /Users/anhdle14/homebrew/Cellar/hgrep/0.2.1/bin/hgrep                                                                                                                                                                                                                                                                        

Still same issue I afraid

@rhysd rhysd reopened this Nov 25, 2021
@rhysd
Copy link
Owner

rhysd commented Nov 25, 2021

Would you check /Users/anhdle14/homebrew/Homebrew/Library/Taps/rhysd/homebrew-hgrep/HomebrewFormula/hgrep.rb is the same as https://github.com/rhysd/hgrep/blob/main/HomebrewFormula/hgrep.rb ?

@rhysd
Copy link
Owner

rhysd commented Nov 25, 2021

It's weird that (bin/'hgrep').exist? returns true but running the binary through zsh says 'no such file or directory'.

@anhdle14
Copy link
Author

anhdle14 commented Nov 25, 2021

@rhysd Yes it is the same (checked with diff). Let's me try to find hgrep in homebrew directory to see where it is installed.


EDIT 1:

❯ find . -name hgrep*
./var/homebrew/locks/hgrep.formula.lock
./Library/Taps/rhysd/homebrew-hgrep/HomebrewFormula/hgrep.rb
❯ find /usr/local/bin -name hgrep*
# return nothing
❯ find /usr/bin -name hgrep*
# return nothing

EDIT 2:

This work:

  def install
    bin.install 'hgrep'
    # hgrep = bin/'hgrep'
    # Check if hgrep exists to avoid #6
    # if hgrep.exist?
      # output = Utils.safe_popen_read(hgrep, '--generate-completion-script', 'zsh')
      # (zsh_completion/'_hgrep').write output
      # output = Utils.safe_popen_read(hgrep, '--generate-completion-script', 'bash')
      # (bash_completion/'hgrep').write output
      # output = Utils.safe_popen_read(hgrep, '--generate-completion-script', 'fish')
      # (fish_completion/'hgrep.fish').write output
    # end
  end

@rhysd
Copy link
Owner

rhysd commented Nov 25, 2021

Thank you for checking that.

It means that

hgrep = bin/'hgrep'
hgrep.exist?

returns true but

Utils.safe_popen_read(hgrep, '--generate-completion-script', 'zsh')

raises an exception with error zsh: no such file or directory.

Can you add debug print as follows and tell me what is output?

 def install
   bin.install 'hgrep'
   hgrep = bin/'hgrep'
+  pp hgrep
   # ...
 end

@rhysd
Copy link
Owner

rhysd commented Nov 25, 2021

I added the check that hgrep is executable or not at 2b33c38. It might help to avoid this issue.

@anhdle14
Copy link
Author

anhdle14 commented Nov 25, 2021

❯ hgrep
dyld[29369]: Library not loaded: /usr/local/opt/pcre2/lib/libpcre2-8.0.dylib
  Referenced from: /Users/anhdle14/homebrew/Cellar/hgrep/0.2.1/bin/hgrep
  Reason: tried: '/usr/local/opt/pcre2/lib/libpcre2-8.0.dylib' (no such file), '/usr/local/lib/libpcre2-8.0.dylib' (no such file), '/usr/lib/libpcre2-8.0.dylib' (no such file)

Also hgrep is pointing to a fixed location of libpcre2. Fix this temporarily to make sure it is working with ln -s ~/homebrew/opt/pcre2/lib/libpcre2-8.0.dylib /usr/local/opt/pcre2/lib/libpcre2-8.0.dylib. Maybe should be another issue for tracking.

P.S: symlink worked.

And I think the hgrep bin doesn't work at all for me without libpcre. If libpcre is available then the homebrew should work fine.

@rhysd
Copy link
Owner

rhysd commented Nov 25, 2021

I see. Yes, it's another issue. Since the binary was built in macOS worker on GitHub Actions and Homebrew is installed system-global there.

In your case, installing hgrep via cargo would be easier if you have installed Rust toolchain. It installs softwares by building from sources so it should not cause this kind of issues.

cargo install hgrep

@anhdle14
Copy link
Author

@rhysd yeah we can close this issue now. I already installed via cargo after the issue, but it is good to create an issue to find the problem with Homebrew installation.

Anyway thank you for the tool and the support!

@rhysd
Copy link
Owner

rhysd commented Nov 25, 2021

Thank you for letting me know. I didn't notice this because I didn't install Homebrew in user-local. I'll check this when I have time.

@rhysd
Copy link
Owner

rhysd commented Nov 25, 2021

I changed to link pcre2 statically on building release binaries. The dynamic link issue should be solved at the next release.

@anhdle14
Copy link
Author

Thank you for letting me know. I didn't notice this because I didn't install Homebrew in user-local. I'll check this when I have time.

https://github.com/drduh/macOS-Security-and-Privacy-Guide

I did at first, but then I came upon this awesome repo explaining why I should not. Feel free to follow if you have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants