Search code examples
macosopencvoperating-systemhomebrew

Homebrew on Mac not using the edited opencv.rb file via brew edit opencv during installation


I tried to install opencv on Mac using Homebrew and edited the opencv.rb file using brew edit

opencv to change -DBUILD_opencv_text=OFF to -DBUILD_opencv_text=ON. However, it seems that the

installation process used the opencv.rb file configured in git instead of the edited one.

As a result, I cannot find the "/usr/local/Cellar/opencv/4.7.0_3/share/java" folder after the

installation completed.

Below are the results of the brew info and brew doctor commands: MacBookPro ~ % brew doctor Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: You have unlinked kegs in your Cellar. Leaving kegs unlinked can lead to build trouble and cause formulae that depend on those kegs to fail to run properly once built. Run the brew link on these: opencv

Warning: You have uncommitted modifications to Homebrew/homebrew-core. If this is a surprise to you, then you should stash these modifications. Stashing returns Homebrew to a pristine state but can be undone should you later need to do so for some reason. cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core && git stash -u && git clean -d -f

Uncommitted files: M Formula/opencv.rb

Warning: Homebrew's "sbin" was not found in your PATH but you have installed formulae that put executables in /usr/local/sbin. Consider setting your PATH for example like so: echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.zshrc

Warning: Your Xcode (14.2) is outdated. Please update to Xcode 14.3 (or delete it). Xcode can be updated from the App Store.

What can I do to solve this problem?

p.s Ant is already installed.

  1. brew edit opencv
  2. -DBUILD_opencv_text=OFF > DBUILD_opencv_text=ON
  3. brew install --build-from-source opencv
  4. Log ScreenShot ==> Fetching opencv ==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/69e9dc686649117e61ab8fe0d82be1def367f25c/Formula/opencv.rb

install After


Solution

  • Basically, every time you edit the formula with brew edit formula and then reinstall from source, it downloads again a new formula so it won't take in considerations your edit of -DBUILD_opencv_text=ON. So, what you can do is install opencv with homebrew with by providing a local formula.

    1. Download formula wherever you want
    2. Make the desired changes with a text editor
    3. brew install --build-from-source /yourPath/opencv.rb