Brew Formula: How can I define external dependencies? - macos

I’m writing a brew formula for my own tap, having XQuartz and external sources (not available on brew) as dependencies. How can I include them in my formula?

See the answer on the brew discourse: https://discourse.brew.sh/t/brew-formula-how-can-i-define-external-dependencies/2358/3.
You need to install those sources by using an existing tap or creating a new one.

Related

install specific maven version in macos using brew

I am trying to install maven 3.6.3 by brew command but not working as latest is maven 3.8.2
brew install maven
Any idea??
Most Homebrew formulae are named in such a way that the version is part of the formula's name. For example, maven#3.5.
Check out the specs for the maven formula: https://formulae.brew.sh/api/formula/maven.json. You'll find that maven has the alias maven#3.8. Usually, formulae without version numbers have an alias with the version number. However, maven#3.8 is not its own package.
However, there are some versioned formulae. For example, maven#3.5, found here.
Long-story short, if you look at versioned_formulae in the maven formula, you'll find that there is no formulae for Maven 3.6. Not sure why because I am positive that it used to be.
You could try writing your own formula or downloading the specific version from the website: https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/.

'fop is missing' while installing Erlang using asdf in Mac

I'm getting the below error while trying to install Erlang using ASDF.
fop is missing
using fakefop to generate placeholder pdf file.
What can I do to fix it?
fop is used to generate documentation in PDF format. You probably won't need it, as most of the time it's easier to look up things in the documentation online, either on the official site, http://erlang.org/doc/, or using the alternative interface at https://erldocs.com/.
So you can safely ignore this error message.
Install fop:
https://xmlgraphics.apache.org/fop/
I've never bothered, though.
I have this error when trying to install Erlang 24.0.5. So, I installed the fop dependency:
brew install libxslt fop
But as mentioned this was not the root cause of my installation issue.
So, I run:
export KERL_CONFIGURE_OPTIONS="--without-wx --without-javac"
asdf install erlang <version>
and I was able to finish the erlang install.
References:
https://github.com/asdf-vm/asdf-erlang#osx
https://erlangforums.com/t/erlang-installation-using-kerl-on-mac-m1-openssl-dependency/1306/5

Mac OSX. Where can I download glibtool?

I am trying to setup watchman for the mac. As stated on the website, I need to install glibtool.
Can anyone provide a link to where I can download glibtool?
I need to be able to download it from its source and the only solution I can find is by using brew.
I do not want to use brew.
Thank you.
glibtool is "GNU Libtool". It is typically installed as libtool on most systems, but because macOS has its own libtool that has completely different functionality, it is usually installed as glibtool on macOS.
If you can't directly use homebrew to install it, you can duplicate the steps in its recipe, which you can find here: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libtool.rb
For the sake of keeping this answer "working" even if homebrew goes away, the homepage for libtool is https://www.gnu.org/software/libtool/ and you can follow the instructions there for information on how to build and install it.
I've covered similar issues to Wez's answer from a MacPorts perspective; I'll go ahead and assume you can't use that either.
The latest stable version at this time is 2.4.6. Typical best practice is to make a directory, e.g., build in the top level of the source. Add the prefix: g, with --program-prefix=g, the top level installation directory --prefix=PREFIX, or specify more fine-grained installation directories options for bin, include, lib, and share directories.
> mkdir build
> cd build
> ../configure --prefix=/my/install/path --program-prefix=g
> make; make install
You now have glibtool and glibtoolize in $PREFIX/bin.

Syntax for a Homebrew formula depending on a cask

I'm writing a homebrew formula for a project (https://www.cryfs.org).
Since it is a file system, it depends on osxfuse, which is unfortunately only available as a cask. That is, the formula should have the cask as a dependency.
I tried the following
depends_on :cask => "osxfuse"
but I got the error message
Unsupported special dependency :cask
What is the syntax for adding casks as dependencies to a formula?
Couldn't find an answer to this problem either.
But as a poor mans workaround this serves well for the time being:
def install
# Resolve cask dependencies
system "/usr/local/bin/brew", "cask", "install", "osxfuse"
The big disadvantage is obvious, its not a so much of dependency relation than an installation command. Which may lead to problems until you actually install the package.
Based on other formulas it seems like it needs to be depends_on cask: instead of :cask. There are multiple places where modules depend on a specific cask/macosx version and are defined as such: depends_on macos: "". Example of an cask dependency inside a cask formula.
depends_on cask: => "osxfuse"
Give me an heads up if it worked!
Have you tried:
depends_on "caskroom/cask/osxfuse"

Installing Google Protocol Buffers on mac

I would like to install the older version of Google Protocol Buffers (protobuf-2.4.1) on Mac using the command line/Terminal app.
I tried with brew install protobuf, but the latest version 2.5.0 has been installed.
Is it possible to install the older version from the terminal?
There are some issues with building protobuf 2.4.1 from source on a Mac. There is a patch that also has to be applied. All this is contained within the homebrew protobuf241 formula, so I would advise using it.
To install protocol buffer version 2.4.1 type the following into a terminal:
brew tap homebrew/versions
brew install protobuf241
If you already have a protocol buffer version that you tried to install from source, you can type the following into a terminal to have the source code overwritten by the homebrew version:
brew link --force --overwrite protobuf241
Check that you now have the correct version installed by typing:
protoc --version
It should display 2.4.1
This is not via brew, but the end result is the same.
Download the protobuf-2.4.1 from https://github.com/protocolbuffers/protobuf/releases/tag/v2.4.1
Extract the tar.gz file.
$cd ~/Downloads/protobuf-2.4.1
$./configure
$make
$make check
$sudo make install
$which protoc
$protoc --version
Steps 4-7 are from the README.txt file from the protobuf tarball.
If you landed here looking for how to install Protocol Buffers on Mac, it can be done using Homebrew by running the command below
brew install protobuf
It installs the latest version of protobuf available. For me, at the time of writing, this installed the v3.7.1
If you'd like to install an older version, please look up the available ones from the package page Protobuf Package - Homebrew and install that specific version of the package.
The oldest available protobuf version in this package is v3.6.1.3
It's a new year and there's a new mismatch between the version of protobuf in Homebrew and the cutting edge release. As of February 2016, brew install protobuf will give you version 2.6.1.
If you want the 3.0 beta release instead, you can install it with:
brew install --devel protobuf
For some reason I need to use protobuf 2.4.1 in my project on OS X El Capitan. However homebrew has removed protobuf241 from its formula. I install it according #kksensei's answer manually and have to fix some error during the process.
During the make process, I get 3 error like following:
google/protobuf/message.cc:130:60: error: implicit instantiation of undefined template 'std::__1::basic_istream<char, std::__1::char_traits<char> >'
return ParseFromZeroCopyStream(&zero_copy_input) && input->eof();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:108:28: note: template is declared here
class _LIBCPP_TYPE_VIS basic_istream;
^
google/protobuf/message.cc:135:67: error: implicit instantiation of undefined template 'std::__1::basic_istream<char, std::__1::char_traits<char> >'
return ParsePartialFromZeroCopyStream(&zero_copy_input) && input->eof();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:108:28: note: template is declared here
class _LIBCPP_TYPE_VIS basic_istream;
^
google/protobuf/message.cc:175:16: error: implicit instantiation of undefined template 'std::__1::basic_ostream<char, std::__1::char_traits<char> >'
return output->good();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:110:28: note: template is declared here
class _LIBCPP_TYPE_VIS basic_ostream;
^
(Sorry, I dont know how to attach code when the code contains '`' )
If you get the same error, please edit src/google/protobuf/message.cc, add #include <istream> at the top of the file and do $ make again and should get no errors. After that do $ sudo make install. When install finished $protoc --version should display the correct result.
From https://github.com/paulirish/homebrew-versions-1 . Works for me!
brew install https://raw.githubusercontent.com/paulirish/homebrew-versions-1/master/protobuf241.rb
I used macports
sudo port install protobuf-cpp
To install Protocol Buffer (as of today version v3.7.0)
Go to this website
download the zip file according to your OS (e.g.: protoc-3.7.0-osx-x86_64.zip). This applies also to other OS.
Move the executable in protoc-3/bin/protoc to one of your directories in PATH. In Mac I suggest to put it into /usr/local/bin
Now your good to go 💪🏾
(optional) There is also an include file, you can add. This is a snippet of the README.md
If you intend to use the included well known types then don't forget to
copy the contents of the 'include' directory somewhere as well, for example
into '/usr/local/include/'.
Please refer to our official github site for more installation instructions:
https://github.com/protocolbuffers/protobuf
brew install --devel protobuf
If it tells you "protobuf-2.6.1 already installed":
1. brew uninstall --devel protobuf
2. brew link libtool
3. brew install --devel protobuf
There is another official way by Google, as mentioned by another user.
Read it fully before trying.
Here are the steps:
Open Terminal and type the following
PROTOC_ZIP=protoc-3.7.1-osx-x86_64.zip
curl -OL https://github.com/google/protobuf/releases/download/v3.7.1/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
rm -f $PROTOC_ZIP
Worked for me.
P.S.
This is for version 3.7.1 in osx only.
If you want to install some other version/platform, visit the releases link and check out the details of the latest version, and use those information.
Reference
FWIW., the latest version of brew is at protobuf 3.0, and doesn't include any formulae for the older versions. This is somewhat "inconvenient".
While protobuf may be compatible at the wire level, it is absolutely not compatible at the level of generated java classes: you can't use .class files generated with protoc 2.4 with the protobuf-2.5 JAR, etc. etc. This is why updating protobuf versions is such a sensitive topic in the Hadoop stack: it invariably requires coordination across different projects, and is traumatic enough that nobody likes to do it.
HomeBrew versions has been removed and formulaes have been emptied. Therefore, my advice is to install it manually following the following steps.
For the time being you will need to build and install the Protocol Buffers toolset manually.
Download source code: https://github.com/google/protobuf/releases/download/v2.4.1/protobuf-2.4.1.tar.gz
tar xvfz protobuf-2.4.1.tar.gz
cd protobuf-2.4.1
Run ./configure
Edit src/google/protobuf/message.cc, add #include at the top of the file
Run make command from root of the folder, i.e. protobuf-2.4.1/
Run sudo make install
Run /usr/local/bin/protoc --version to check the version of protobuf compiler version
The terminal output should be:
Version: libprotoc 2.4.1
you can install from official link page provided by google http://google.github.io/proto-lens/installing-protoc.html
For v3 users.
http://google.github.io/proto-lens/installing-protoc.html
PROTOC_ZIP=protoc-3.7.1-osx-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP
There should be better ways but what I did today was:
Download from https://github.com/protocolbuffers/protobuf/releases (protoc-3.14.0-osx-x86_64.zip at this moment)
Unzip (double click the zip file)
Here, I added a symbolic link
ln -s ~/Downloads/protoc-3.14.0-osx-x86_64/bin/protoc /usr/local/bin/protoc
Check if works
protoc --version

Resources