I've written a brew formula (below) for xnec2c but I get this error. What about the xnec2c installer is causing brew to bark about the installation process? I'm the maintainer for xnec2c so we can change the ./configure or make install process as necessary. This is brew for Linux (on Ubuntu 20.04) and ultimately I would like to see if it runs on OSX, too!
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /home/linuxbrew/.linuxbrew
Could not symlink share/mime/XMLnamespaces
Target /home/linuxbrew/.linuxbrew/share/mime/XMLnamespaces
already exists. You may want to remove it:
rm '/home/linuxbrew/.linuxbrew/share/mime/XMLnamespaces'
To force the link and overwrite all conflicting files:
brew link --overwrite xnec2c
To list all files that would be deleted:
brew link --overwrite --dry-run xnec2c
Possible conflicting files are:
/home/linuxbrew/.linuxbrew/share/mime/XMLnamespaces
/home/linuxbrew/.linuxbrew/share/mime/aliases
/home/linuxbrew/.linuxbrew/share/mime/generic-icons
/home/linuxbrew/.linuxbrew/share/mime/globs
/home/linuxbrew/.linuxbrew/share/mime/globs2
/home/linuxbrew/.linuxbrew/share/mime/icons
/home/linuxbrew/.linuxbrew/share/mime/magic
/home/linuxbrew/.linuxbrew/share/mime/mime.cache
/home/linuxbrew/.linuxbrew/share/mime/subclasses
/home/linuxbrew/.linuxbrew/share/mime/treemagic
/home/linuxbrew/.linuxbrew/share/mime/types
/home/linuxbrew/.linuxbrew/share/mime/version
Note that it does work if I run brew link --overwrite xnec2c but I'd like the formula to install cleanly!
Here is the formula:
class Xnec2c < Formula
desc "Multi-threaded EM tool based on NEC2 to model antenna radiation patterns"
homepage "https://www.xnec2c.org/"
url "https://www.xnec2c.org/releases/xnec2c-v4.4.12.tar.gz"
sha256 "e98af1e8b9098df9cc03f90950358b846cc6a2965e79c0114ab711fbe51272c5"
license "GPL-3.0-or-later"
depends_on "atk"
depends_on "cairo"
depends_on "gdk-pixbuf"
depends_on "glib"
depends_on "gtk+3"
depends_on "librsvg"
depends_on "pango"
depends_on "autoconf"
depends_on "automake"
def install
system "./autogen.sh"
system "./configure", *std_configure_args
system "make"
system "make install"
system "make desktop-install"
end
test do
system "#{bin}/xnec2c", "-h"
end
end
Because you have a conflict in the setup, that is why you brew link <formula>. Ideally, we also have conflicts_with semantics in the formula to surface that.
This is all the conflicts in the homebrew-core repo, https://github.com/search?q=repo%3Ahomebrew%2Fhomebrew-core+conflicts_with&ref=opensearch&type=code
Related
Can not get NGINX to install with passenger
Following the steps you are supposed to...
brew install passenger
Then you run the following command...
brew install nginx --with-passenger
But I get:
Error: invalid option: --with-passenger
Could not find any resources about this online, so asking here.
$ brew install nginx --with-passenger
Usage: brew install [options] formula
Install formula.
formula is usually the name of the formula to install, but it can be specified
in several different ways.
-d, --debug If brewing fails, open an interactive
debugging session with access to IRB or a
shell inside the temporary build directory
--env If std is passed, use the standard build
environment instead of superenv.If super
is passed, use superenv even if the formula
specifies the standard build environment.
--ignore-dependencies Skip installing any dependencies of any
kind. If they are not already present, the
formula will probably fail to install.
--only-dependencies Install the dependencies with specified
options but do not install the specified
formula.
--cc Attempt to compile using provided
compiler. compiler should be the name
of the compiler's executable, for instance
gcc-7 for GCC 7. In order to use LLVM's
clang, use llvm_clang. To specify the
Apple-provided clang, use clang. This
parameter will only accept compilers that
are provided by Homebrew or bundled with
macOS. Please do not file issues if you
encounter errors while using this flag.
-s, --build-from-source Compile the specified formula from source
even if a bottle is provided. Dependencies
will still be installed from bottles if
they are available.
--force-bottle Install from a bottle if it exists for the
current or newest version of macOS, even if
it would not normally be used for
installation.
--include-test Install testing dependencies required to
run brew test.
--devel If formula defines it, install the
development version.
--HEAD If formula defines it, install the HEAD
version, aka. master, trunk, unstable.
--fetch-HEAD Fetch the upstream repository to detect if
the HEAD installation of the formula is
outdated. Otherwise, the repository's HEAD
will be checked for updates when a new
stable or development version has been
released.
--keep-tmp Don't delete the temporary files created
during installation.
--build-bottle Prepare the formula for eventual bottling
during installation.
-f, --force Install without checking for previously
installed keg-only or non-migrated
versions.
-v, --verbose Print the verification and postinstall
steps.
--display-times Print install times for each formula at the
end of the run.
-i, --interactive Download and patch formula, then open a
shell. This allows the user to run
./configure --help and otherwise
determine how to turn the software package
into a Homebrew package.
-g, --git Create a Git repository, useful for
creating patches to the software.
-h, --help Show this message.
Error: invalid option: --with-passenger
This is supposed to work... so yeah.
A late answer. Obviously the documentation on the passenger site is outdated at time of this writing.
According to phusion's github site
https://github.com/phusion/passenger/issues/2187#issue-416881033
the config option --nginx-with-passenger is not valid anymore.
Instead do:
brew install nginx passenger
Addendum:
When using google search for results currently the old page comes up at the top of the list. Here's the currently maintained page with the accurate information:
https://www.phusionpassenger.com/docs/advanced_guides/install_and_upgrade/nginx/install/oss/osx.html
After updating gcloud I get this warning, but how do I do it(Should I remove Docker)?
WARNING: There are older versions of Google Cloud Platform tools on your system PATH.
Please remove the following to avoid accidentally invoking these old tools:
/Applications/Docker.app/Contents/Resources/bin/kubectl
I have this in my .zshrc:
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/<NAME>/google-cloud-sdk/path.zsh.inc' ]; then source '/Users/<NAME>/google-cloud-sdk/path.zsh.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/<NAME>/google-cloud-sdk/completion.zsh.inc' ]; then source '/Users/<NAME>/google-cloud-sdk/completion.zsh.inc'; fi
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
This happens because docker-for-mac installs a bin for kubectl, and gcloud-sdk also installs another bin with gcloud components install kubectl.
My recommendation is to uninstall kubectl as component from gcloud, overwrite the symlink from docker-for-mac, and only use the homebrew installed bin.
Try this commands:
gcloud components remove kubectl
brew install kubernetes-cli
brew link --overwrite kubernetes-cli
TLDR
/usr/local/bin/kubectl is a link installed by Docker: ls -l /usr/local/bin/kubectl => /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl. Removing the link has no side effects and solves the conflict:
rm /usr/local/bin/kubectl
Justification
The conflict is with the Docker-provided version of kubectl so it makes sense to check what Docker docs have to say about it. https://docs.docker.com/desktop/kubernetes/#use-the-kubectl-command
Extract:
If you installed kubectl using Homebrew, or by some other method, and experience conflicts, remove /usr/local/bin/kubectl.
Here is my case you can refer to. After running gcloud components update, I got this warning:
WARNING: There are older versions of Google Cloud Platform tools on your system PATH.
Please remove the following to avoid accidentally invoking these old tools:
/usr/local/Cellar/kubernetes-cli/1.10.2/bin/kubectl
I check this tool using brew list
☁ issue [master] brew list
coreutils gdbm git-lfs icu4c kops kubectx libpng mtr openssl python#2 sqlite tree wxmac
erlang geoip git-redate jpeg kube-ps1 kubernetes-cli libtiff node pcre readline telnet watchman
After reading the doc. I decided to uninstall kubernetes-cli and its dependencies kops, kube-ps1, and kubectx to avoid the conflicts.
☁ issue [master] brew uninstall kops kube-ps1 kubectx
Uninstalling /usr/local/Cellar/kops/1.9.0... (5 files, 129.8MB)
Uninstalling /usr/local/Cellar/kube-ps1/0.6.0... (6 files, 29.0KB)
Uninstalling /usr/local/Cellar/kubectx/0.5.0... (12 files, 27.8KB)
☁ issue [master] brew uninstall kubernetes-cli
Uninstalling /usr/local/Cellar/kubernetes-cli/1.10.2... (178 files, 52.8MB)
☁ issue [master] gcloud components update
All components are up to date.
This warning is gone.
I just went into the Docker file's bin folder and moved the kubectl to the trash.
Do echo $PATH and check which folder takes precedence. In my case it is like .../Users/myname/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:.... Here the kubectl in gcloud is actually before the kubectl from Docker Desktop (which is in /usr/local/bin/kubectl) so there is no problem. If this is also your case you don't need to do anything.
Of course, if you want to completely remove confusion you can just delete the link /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl, or rename it.
Update:
In the recent docker desktop releases they actually provided another link /usr/local/bin/kubectl.docker -> /Applications/Docker.app/Contents/Resources/bin/kubectl to differentiate it from other kubectl so it is not a bad idea to just simply delete the link /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl
I need install imagick module on my php 7.2
I see
brew search php72
==> Searching local taps...
==> Searching taps on GitHub...
==> Searching blacklisted, migrated and deleted formulae...
No formula found for "php72".
Closed pull requests:
...
php72-imagick 3.4.3 (new formula) (https://github.com/Homebrew/homebrew-php/pull/4267)
How can I do it?
Also I need support for argon
It all changed back in April 2018 I think. Homebrew no longer acts as the package manager for PHP, so all the php-imagick and php-redis and php-other-extension stuff has gone and you are now supposed to manage PHP packages using pecl like everyone else does.
So, how to get Imagick under PHP? Note that Imagick and ImageMagick are two different things:
ImageMagick is the entire ImageMagick suite
Imagick is just the PHP binding
Here are the steps - if anyone knows better or any improvements, let me know via comment and I will update.
Step 1 - Delete anything likely to conflict
Before starting, it is best to clean up all the stuff that is broken or unneeded. Do as many of these as you are comfortable with:
brew rm php php#5.6 php#7.0 php#7.1
brew rm imagemagick
Step 2 - Update Xcode command line tools and get build packages
Make sure you have installed Xcode command-line tools with:
xcode-select --install
Go to AppStore and click on Updates and update any Xcode related packages - especially if you have recently upgraded macOS.
Install homebrew building tools:
brew install pkg-config
Step 3 - Install ImageMagick
Check what ImageMagick options you want with:
brew options imagemagick
I like to use:
brew install imagemagick --with-x11 --with-librsvg --with-openexr --with-pango
hash -r
but you may like vanilla install:
brew install imagemagick
hash -r
Step 4 - Install homebrew PHP
Next, install the homebrew version of PHP with:
brew install php
hash -r # Update bash's internal paths
Now, critically ensure you are running the correct homebrew PHP:
type php
If that tells you:
/usr/local/...anything.../php
you are running homebrew PHP and you can go to the next step.
If it tells you:
/usr/bin/php
you are running the Apple-supplied PHP. If that is what you want to run, ignore my entire answer which is predicated on you wanting to use homebrew PHP. If you get this answer but want to run homebrew PHP, your PATH is set incorrectly. You need to put /usr/local/bin before /usr/bin to pick up all homebrew packages ahead of Apple programs, i.e.
export PATH=/usr/local/bin:$PATH
This step gives you pecl - the PHP Package Manager - as well, since it is part of homebrew PHP.
Step 5 - Install Imagick
Now you can install Imagick with pecl:
pecl install imagick
If anything goes wrong, here are some related questions and answers...
Q1. How can I find where my php.ini file is?
Try any of these commands:
pecl config-get php_ini # I get "/usr/local/etc/php/7.2/php.ini"
brew info php
php -i | grep "Loaded Configuration" # I get "Loaded Configuration File => /usr/local/etc/php/7.2/php.ini"
Q2. How can I find where pecl installs modules?
pecl config-get ext_dir # I get "/usr/local/lib/php/pecl/20170718"
Q3. How can I tell what PHP modules are loaded?
php -m
Q4. Why can't PHP find my module?
First locate your modules directory using Q2. I like to put that in the clipboard with:
pecl config-get ext_dir | pbcopy
Then edit the php.ini file from Q1. I use vi, so I would do:
vi "$(pecl config-get php_ini)"
Then find the line in that file that looks like this:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
and, then (using the contents of your paste buffer) make the following line look like this (no semi-colon at the start):
extension_dir = "/usr/local/lib/php/pecl/XXXXXX"
on my machine XXXXXX is 20170718. If you get this right, any and all modules you install via pecl will be visible to your homebrew PHP.
Q5. How can I see all my PHP settings?
Check PHP configuration, versions and settings with:
php -i
In my case (PHP 7.2.10 with Homebrew) works:
pecl install imagick
Open the file php.ini and remove extension line with imagick extension.
Check *.ini files with
php --ini
You can see paths to extension files. Create or edit imagick ini file.
subl /usr/local/etc/php/7.2/conf.d/ext-imagick.ini
The content of file may be (check the path to imagick.so)
[imagick]
extension="/usr/local/opt/php/pecl/20170718/imagick.so"
And restart php with
brew services restart php
Try, if the error message dissapear:
php -v
And check imagick extension with:
php -i | grep imagick
If you see line with imagick module => enabled you have solved a problem.
You want php72-gmagick, GraphicsMagick is a fork from ImageMagick 5.5.2.
Or, you can pecl install imagick still.
Is there a way to brew link just those files without conflicts?
As near as I can tell, the only options are to force an overwrite of all conflicting roles, or to link no files at all. For example I have an existing compare that I need to keep, but need ImageMagick's convert. When I brew install imagemagick I get
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/compare
Target /usr/local/bin/compare
already exists. You may want to remove it:
rm '/usr/local/bin/compare'
To force the link and overwrite all conflicting files:
brew link --overwrite imagemagick
To list all files that would be deleted:
brew link --overwrite --dry-run imagemagick
Possible conflicting files are:
/usr/local/bin/compare -> /Applications/Araxis Merge.app/Contents/Utilities/compare
But the only way offered to proceed is either to leave all of ImageMagick unlinked, or to overwrite my existing compare.
How do I brew link everything but the existing compare? Is there a way to install only convert perhaps?
Here's a shell function I wrote to do this (for the zsh that's now standard on macOS, but it will run on Bash with small adjustments 1):
local targetdir
targetdir=($(brew --cellar $1)/*/bin) || return
local linksdir=$(brew --repo)/bin
for ex in "$targetdir"/*(^/) # files (and symlinks), not subdirectories
do
local exname=${ex##*/}
if builtin which "$exname" &>/dev/null
then
echo " $exname already available in the path - skipped"
else
ln -s "$ex" "$linksdir/" && echo "$exname linked from $linksdir"
fi
done
I saved it as a shell function called blink and when I call it with a package name, like
blink binutils
it symlinks only the binaries whose names aren't already available in the $PATH.
1The adjustments to make it work on Bash: remove the final (^/) form the for ex... line, and the builtin 3 lines further down.
Context
I have some functions defined in my ~/.bashrc which I'd like to turn into a Homebrew package. Currently, these functions act as custom commands on my command line:
# .bashrc
function foo() {
# do something interesting
}
# at terminal
$ foo
# => does the interesting thing
Approach
I've created a homebrew formula using brew create. My current approach is as follows:
Move the function definitions into a separate file, script, within a directory, brew-script
Make brew-script downloadable as a tarball, brew-script.tar.gz
Have my brew formula append text to the end of ~/.bash_profile to include script when terminal session starts
Concerns
Is modifying .bash_profile in a brew formula bad practice? (eg. when uninstalling with brew uninstall script, brew should somehow remove the text that was appended to .bash_profile... Parsing .bash_profile doesn't seem very fun.)
Is there a convention already established for including functions in bash scripts so that they are available from the command line?
Is it common to simply ask the user to add some text to their .bash_profile or .bashrc?
Desired result
Should be able to install cleanly with brew and then run foo as a command:
$ brew install script
$ foo
# => does the interesting thing
(Assume the brew formula is already installed locally. I'll worry about auditing and pushing the formula to homebrew later)
Refer https://github.com/Homebrew/homebrew/issues/50232 and https://github.com/Homebrew/homebrew/issues/50231.
I have a script that safely‡ modifies ~/.bash_profile as part of a homebrew install process. https://github.com/paul-hammant/homebrew-tap/blob/master/switchjdk.rb
‡ allegedly
Without using homebrew:
to put your bash scripts in some file such as bashrc or any other name works, then put the following line:
source "path/to/brew-script/script"
somewhere in your bash profile.
Then you just have to make sure you refresh or reload your bash profile by running . ~/.bash_profile or source ~/.bash_profile.
How homebrew installs work:
When you installed homebrew it added a line to your bash_profile that modifies your $PATH variable to include the path to the homebrew install repo, so that whenever brew installs something it becomes findable through your PATH.
If you use brew create you must have your script uploaded somewhere on the internet, because the argument brew install takes is a URL. I.e if I create my script at my_bash_function.tar.gz then I would do
brew create http://web.mit.edu/dianah13/www/my_bash_function.tar.gz
It also templates a pull request to include your package in homebrew's main repo.