Homebrew: install new formula php72-imagick - homebrew

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.

Related

Link hadoop installed with sdkman to brew

I installed hadoop with sdkman and now I'm trying to install Hive with homebrew but brew wants to install hadoop again because it doesn't know hadoop is already installed on my computer.
I use --ignore-dependencies flag as workaround but it's not a best practice.
Do you know how can I link my hadoop installation done with sdkman to brew?
It is not possible to use a non-Homebrew hadoop with Homebrew hive, see https://docs.brew.sh/Building-Against-Non-Homebrew-Dependencies
To improve quality and reduce variation, Homebrew now exclusively supports using the default formula, as an ordinary dependency, and no longer supports using arbitrary alternatives.
You will have to install Hive manually: https://cwiki.apache.org/confluence/display/hive/gettingstarted#GettingStarted-InstallingHivefromaStableRelease
Installing Hive from a Stable Release
Start by downloading the most recent stable release of Hive from one of the Apache download mirrors (see Hive Releases).
Next you need to unpack the tarball. This will result in the creation of a subdirectory named hive-x.y.z (where x.y.z is the release number):
$ tar -xzvf hive-x.y.z.tar.gz
Set the environment variable HIVE_HOME to point to the installation directory:
$ cd hive-x.y.z
$ export HIVE_HOME={{pwd}}
Finally, add $HIVE_HOME/bin to your PATH:
$ export PATH=$HIVE_HOME/bin:$PATH

Anyone else get this error "Error: invalid option: --with-passenger"

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

asdf-erlang doesn't install man pages

I am using asdf + asdf-erlang as my version manager for Erlang. All seems to be working fine, except that typing erl -man mnesia results in No manual entry for mnesia.
I have installed all dependencies mentioned on the asdf-erlang github page. I have also installed xsltproc and fop. Unfortunately "man" folder located under ~/.asdf/installs/erlang/18.3/lib/erlang/erts-73/ is empty. I haven't found man pages being generated elsewhere.
I was trying to locate build log, but I was not successful with that either.
I am using 64bit Ubuntu 16.10 & 16.04.
OK. I finally managed to resolve the issue:
Go to https://www.erlang.org/downloads/ and download manpages for the version(s) of Erlang you have installed using asdf (so for 18.3 you're looking for: http://erlang.org/download/otp_doc_man_18.3.tar.gz)
Copy man folder with its content (extracted from the archive) to ~/.asdf/installs/erlang/<version>/lib/erlang/. After doing so, you should have .~/asdf/installs/erlang/<version>/lib/erlang/man containing man1, man3, man4, man6, man7 (and each of those folders should have some manpages in it).
Repeating steps above for all the versions installed using asdf, allows you to use manpages for specific version of Erlang you are using at the moment.
looks like erlang-manpages are not included in the asdf-erlang since you are using ubuntu i would suggest you add Erlang Solutions repository to your system, call the following commands:
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
sudo apt-get update
then install erlang-manpages:
sudo apt-get install erlang-manpages
you could also install erlang-doc — HTML/PDF documentation
sudo apt-get install erlang-doc
check this page for more information
The man path in #MaciekTalaska 's answer seems not correct, it does not work at all, for erlang 18.3.
After reading ASDF's activate script(), here's one statement:
_KERL_MANPATH_REMOVABLE="$HOME/.asdf/installs/erlang/18.3/lib/erlang/man:$HOME/.asdf/installs/erlang/18.3/man"
Therefore, you just need to:
Go to https://www.erlang.org/downloads/ and download manpages for the version(s) of Erlang you have installed using asdf (so for 18.3 you're looking for: http://erlang.org/download/otp_doc_man_18.3.tar.gz)
Copy man folder with its content (extracted from the archive) to $HOME/.asdf/installs/erlang/${version}, but not $HOME/.asdf/installs/erlang/${version}/lib/erlang/ (in fact, there isn't a folder named erlang under lib).

Configuring ImageMagick in TYPO3

I cannot get ImageMagick to work in TYPO3 6.2.3
If I make a test file with this code:
<?
print "<pre>";
phpinfo();
print "</pre>";
system('/usr/local/bin/safe/convert --help');
?>
I get the PHP output and that doesn't tell anything about ImageMagick. But below that I get the help section from ImageMagick so ImageMagick is installed.
If I put /usr/local/bin/safe/ in the Image handling settings in TYPO3 backend the Test scaling images fail.
What did I miss?
You'll need to install the Imagick PECL extension to be able to use Imagemagick with the PHP language.
sudo pecl install imagick
# Or manually
curl -O http://pecl.php.net/get/imagick-3.2.0RC1.tgz
tar zxvf imagick-3.2.0RC1.tgz
cd imagick-3.2.0RC1
phpize
./configure && make
sudo make install
# Add 'extension=imagick.so' to php.ini
The imagemagick module should show up in your phpinfo(), or be listed when executing php -m
Edit
TYPO3 is expecting to use the convert commands directly. No need for PECL's shared extension.
Ensure the safe path is configured in your php.ini file (see safe_mode_include_dir & safe_mode_exec_dir )
Updated TYPO3's $TYPO3_CONF_VARS['GFX'] to map the convert program & location
$TYPO3_CONF_VARS['GFX']['im'] = 1;
$TYPO3_CONF_VARS['GFX']['im_path'] = '/usr/local/bin/safe/';
Example with GraphicsMagick is a good reference. But phpinfo will not display any information about the Imagemagick version/install using this method.

How do you migrate a Homebrew installation to a new location?

I have a Homebrew installation in $HOME/brew, and historically it has worked well. Unfortunately, over time Homebrew has become less and less tolerant of installations outside of /usr/local. Various formulae make hard assumptions about the installation prefix, and do not work properly (i.e., were not tested) with a non-standard prefix. The brew doctor command even goes so far as to warn about this now:
Warning: Your Homebrew is not installed to /usr/local
You can install Homebrew anywhere you want, but some brews may only build
correctly if you install in /usr/local. Sorry!
As such, I would now like to migrate my Homebrew installation over to /usr/local. However, I am loath to simply mv all the files, as I suspect this will cause problems. I could not find any instructions on the Homebrew site or here on migrating an existing installation to a new prefix. Of course, I could uninstall Homebrew and then reinstall it, but I would prefer not to rebuild all my kegs.
Is there any existing script or documented practice for performing such a migration?
Or is this impossible due to hardcoded absolute paths in linked binaries?
The modern way to do this is with homebrew-bundle.
brew tap Homebrew/bundle
brew bundle dump # Creates 'Brewfile' in the current directory
# later ...
brew bundle # Installs packages listed in 'Brewfile'
I just wrote a script to achieve the goal to migrate homebrew packages to a new system, which also applies for your case (named backup-homebrew.sh):
#!/bin/bash
echo '#!/bin/bash'
echo ''
echo 'failed_items=""'
echo 'function install_package() {'
echo 'echo EXECUTING: brew install $1 $2'
echo 'brew install $1 $2'
echo '[ $? -ne 0 ] && $failed_items="$failed_items $1" # package failed to install.'
echo '}'
brew tap | while read tap; do echo "brew tap $tap"; done
brew list --formula | while read item;
do
echo "install_package $item '$(brew info $item | /usr/bin/grep 'Built from source with:' | /usr/bin/sed 's/^[ \t]*Built from source with:/ /g; s/\,/ /g')'"
done
echo '[ ! -z $failed_items ] && echo The following items were failed to install: && echo $failed_items'
You should first run this script on your original system to generate a restore script:
./backup-homebrew.sh >restore-homebrew.sh && chmod +x restore-homebrew.sh
Then, after installing Homebrew on your new system (in your case the same system), simply run restore-homebrew.sh to install all those packages you have on your original system.
The benefits of this script over the one given by #ctrueden is that this script also tries to back up the installation options you used when you installed the packages.
A more detailed description is in my blog.
As suggested by Peter Eisentraut, I indeed ended up migrating my Homebrew installation by reinstalling it. You can script things a bit to retap all your extra taps, and reinstall all your previously installed kegs, without too much manual work:
#!/bin/sh
# save list of kegs for later reinstallation
brew list > kegs.txt
# back up old Homebrew installation
mv $HOME/brew $HOME/old-brew
# install Homebrew into /usr/local
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
# retap all the taps
# NB: It is not enough to move the tap repos to their new location,
# because Homebrew will not automatically recognize the new formulae.
# There might be a configuration file we could edit, but rather than
# risk an incomplete data structure, let's just retap everything.
for tapDir in $HOME/old-brew/Library/Taps/*
do (
cd $tapDir
tap=$(git remote -v | \
grep '(fetch)' | \
sed 's/.*github.com\///' | \
sed 's/ (fetch)//')
/usr/local/bin/brew tap $tap
) done
# reinstall all the kegs
/usr/local/bin/brew install $(cat kegs.txt)
# much later... ;-)
rm -rf kegs.txt $HOME/old-brew
Of course, customized Homebrew installations will have additional wrinkles. For example, if you have committed changes to any of your Homebrew-related Git repos, you may want to import that work before reinstalling your kegs or blowing away your old installation:
cd /usr/local
for f in $(find . -name '.git')
do (
repoDir=$(dirname $f)
cd $f/..
git remote add old-brew-$f $(dirname $HOME/old-brew/$f/..)
git fetch old-brew-$f
) done
Note that I only tested the second snippet above very lightly, as I personally have not customized my Homebrew in such a way.
Another aspect of Homebrew not addressed by this approach is custom flags using during your original installation. For example, to install wine you need to install various dependencies with the --universal flag, and the script above will not reinstall them with such flags enabled. See #xuhdev's answer for a solution that does so.
Or is this impossible due to hardcoded absolute paths in linked binaries?
Indeed. You'll need to reinstall everything from scratch.

Resources