How to I install Ghostscript 9.21 with homebrew? - homebrew

I'm stuck using Ghostscript 9.21 on my project, and homebrew is installing 9.55. How do I install 9.21? I tried brew install ghostscript#9.21 but the package doesn't have versioning.
I'd like to use https://github.com/Homebrew/homebrew-core/blob/f7092d9202dbfbd9ea0ae70064c59e796b81d5df/Formula/ghostscript.rb but when I brew install https://github.com/Homebrew/homebrew-core/blob/f7092d9202dbfbd9ea0ae70064c59e796b81d5df/Formula/ghostscript.rb I get:
/opt/homebrew/Homebrew/Library/Homebrew/formulary.rb:277:in `load_file': Invalid usage: Installation of ghostscript from a GitHub commit URL is unsupported! `brew extract ghostscript` to a stable tap on GitHub instead. (UsageError)
I haven't been able to figure out how to do it with brew extract as it says.

brew extract was broken, and a fix has been merged. Now you can extract the formula:
Create a Homebrew tap where the formula will be extracted to:
brew tap-new $USER/local-tap
Extract Ghostscript 9.21 to your tap:
brew extract --version=9.21 ghostscript $USER/local-tap
However, there are still some changes that must be made to fix the formula:
Set the HOMEBREW_EDITOR environment variable to your editor of choice. Mine is code
Run brew edit ghostscript#9.21
Delete revision 4 because this is a new formula.
The sha256 hashes of the patches are wrong, probably because a=patch adds the Git version at the bottom of the patch. Let's change a=patch to a=commitdiff_plain and blank out sha256 to get the new hashes later:
patch do
url "https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff_plain;h=4f83478c88"
sha256 ""
end
patch do
url "https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff_plain;h=04b37bbce1"
sha256 ""
end
patch do
url "https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff_plain;h=57f20719e1"
sha256 ""
end
Delete the devel block:
- devel do
- url "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs922rc2/ghostscript-9.22rc2.tar.gz"
- sha256 "1861c0cee1e005bd2712873e3058ee1c131c79819625fe479ebcef68e055648e"
- end
(devel was deprecated somewhat recently.)
Delete depends_on :x11 => :optional (assuming you don't need X11 support)
Also delete if build.without? "x11" like so:
- args << "--without-x" if build.without? "x11"
+ args << "--without-x"
(:x11 has been replaced by the libx11 formula.)
Now run brew install -s ghostscript#9.21 and you'll get the new sha256 hashes mentioned above:
$ brew install -s ghostscript#9.21
==> Downloading https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff_plain;h=4f83478c88
-#O#- # #
Warning: Cannot verify integrity of '86093339e3f806acdd14f4ba35d2748f1c31cd4f5008d39a4646e9036b5cb767--ghostpdl.git-4f83478c88.patch'.
For your reference, the checksum is:
sha256 "fa46ee96c9896a6feb0f23fd4276023477988c904da52e581efbc78c307eb435"
Finally, your formula should look like this.

Related

How to instsall nix-linter

I've tried to install nix-linter with 3 way. None works
nix package manager
nix-env -iA nixpkgs.nix-linter
Package is marked as broken, refusing to evaluate.
It propose me several option to add broken package ( export NIXPKGS_ALLOW_BROKEN=1 ). But I don't understand exactly what will be the repercutions. I prefer not to follow this option
with cachix
I follow this tutorial
and add this line
echo "trusted-users = root myusername" | sudo tee -a /etc/nix/nix.conf && sudo pkill nix-daemon
normally after cachix use nix-linter there is a cache that nix-build use
But it doesn't work. I get an error saying that there is no default.nix in my repository
https://github.com/Synthetica9/nix-linter
cachix use nix-linter
git clone https://github.com/Synthetica9/nix-linter
cd nix-linter
$(nix-build -A nix-linter)/bin/nix-linter --help
error: attribute 'nix-linter' in selection path 'nix-linter' not found
-bash: /bin/nix-linter: No such file or directory
somebody from cacheix said that this package is no longer maintain and I should try statix.
statix works

nix-shell can't find standard attribute

I'm running nixos 19.09 and trying to follow along with the instructions for creating a ruby package. But in one of the first steps I'm getting an error that the withPackages attribute can't be found.
Command:
$ nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])" --show-trace
Result:
while evaluating the attribute 'buildInputs' of the derivation 'shell' at /nix/store/b6cqdsczmwxfkmc65483x7fgwdl129ar-nixpkgs-19.03.173684.c8db7a8a16e/nixpkgs/pkgs/build-support/trivial-builders.nix:7:14:
while evaluating 'getOutput' at /nix/store/b6cqdsczmwxfkmc65483x7fgwdl129ar-nixpkgs-19.03.173684.c8db7a8a16e/nixpkgs/lib/attrsets.nix:464:23, called from undefined position:
while evaluating anonymous function at /nix/store/b6cqdsczmwxfkmc65483x7fgwdl129ar-nixpkgs-19.03.173684.c8db7a8a16e/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:141:17, called from undefined position:
attribute 'withPackages' missing, at (string):1:94
I'm guessing that I messed up my nix store somehow, but I don't know how to debug it.
Additional Info:
$ echo $NIX_PATH
$HOME/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
$ nix-channel --list
nixpkgs https://nixos.org/channels/nixos-19.03
unstable https://nixos.org/channels/nixos-unstable
$ sudo nix-channel --list
<blank>
After #RobertHensing pointed out that it looked like I was on 19.03, and asked me to print out my channels, I tried just updating the channel list to point to 19.09 instead of 19.03 (with nix-channel --add) and that fixed it.

Does nix provide package options / parameters? How do I list them?

For example I can query for available package versions of llvm:
$ nix-env -qa llvm
...
llvm-4.0.1
llvm-5.0.2
llvm-6.0.1
With homebrew I can provider an option when installing a package like llvm, in this case the --shared option:
$ brew install llvm --shared
Does nix support providing package specific options like this? Is there a way to list the available options of a package?
Yes, nix derivations can come with optional arguments. For example, the derivation for LLVM 6 nixpkgs/development/compilers/llvm/6/llvm.nix starts like this:
{ stdenv
, fetch
...
, zlib
, debugVersion ? false
, enableManpages ? false
, enableSharedLibraries ? true
, enableWasm ? true
, darwin
}:
You can supply values for these arguments on the nix-env command line using the options --arg or --argstr, compare the man page. E.g.,
nix-env -iA nixpkgs.llvm --arg enableSharedLibraries false
I'm not aware of an easier way to find out such options than to read the nixpkgs source, unfortunately.

Easy way to have Homebrew list all package dependencies

Is there anyway to have the command brew show all the installed or optional dependencies for any given package? It would also be helpful to see which of the install packages are themselves the dependencies of others packages.
For all packages:
brew deps --tree --installed
For one package only (e.g.):
brew deps --tree --installed vim
Thanks to rob-kovacs for suggesting the --tree addition
See this helpful article for details: https://blog.jpalardy.com/posts/untangling-your-homebrew-dependencies/
Especially if you're interested in creating a graph of the dependency tree.
Here is a command that will list all formulas that aren't dependents of any other formulas (leaves), and for each of them lists all of its dependencies.
Sample output line:
awscli: gdbm readline sqlite tcl-tk xz
Command:
brew leaves | xargs brew deps --formula --for-each | sed "s/^.*:/$(tput setaf 4)&$(tput sgr0)/"
Alternate command without xargs:
brew deps --formula --for-each $(brew leaves) | sed "s/^.*:/$(tput setaf 4)&$(tput sgr0)/"
You can use info command like.
brew info ffmpeg
It will show you information and dependencies of formula. Also, it shows if this package installed by a tick after name of it.
I found the brew deps --tree switch is also very helpful to visualize dependencies just in the command line. From the official doc:
brew deps --tree [--1] [filters] [--annotate] (formulae|--installed):
Show dependencies as a tree. When given multiple formula arguments, output
individual trees for every formula.
Example1:
brew deps --tree fontconfig
Output1:
fontconfig
└── freetype
└── libpng
Example2:
brew deps --tree --1 fontconfig
Output2:
fontconfig
└── freetype
and there are more switches explained by:
brew help deps
Command:
brew deps --include-build --tree $(brew leaves)
Convenient alias:
alias brewdeps="brew leaves | xargs brew deps --include-build --tree"
This way you will get dependencies printed hierarchically and each package will be printed only once.

image::magick not installing with cpan in perl v5.14.2 from dwimperl

I am attempting to rebuild my development/test environment on a new laptop running windows7 32 bit. imageMagick is one of the modules I had installed in an (ancient) version on my old laptop. I have downloaded and installed perl from dwimperl, which is v5.14.2 and had a couple modules install, and several did not.
cpanm Image::Magick - failed
cpanm DB_File - failed
cpanm Time::HiRes - failed
I searched around and found a discussion on magick failing to install on v5.12, but couldn't tell if that was supposed to have been fixed, or if I need to attempt to recreate the fix discussed for 5.12
should I try installing perl from Strawberry? looks like it is a little newer v5.18 ?
is there something I can tweak and re-run cpan installs?
I installed the binaries from imagemagick, from Link first, then cpan again, and cpan still fails....
This is the top part of the build log down to where it really goes south and starts kicking out errors:
cpanm (App::cpanminus) 1.6941 on perl 5.014002 built for MSWin32-x86-multi-thread
Work directory is C:\Users\dtbaker/.cpanm/work/1377281741.8420
You have make C:\Dwimperl\c\bin\dmake.exe
You have LWP 6.03
Falling back to Archive::Tar 1.80
Searching Image::Magick on cpanmetadb ...
--> Working on Image::Magick
Fetching http://www.cpan.org/authors/id/J/JC/JCRISTY/PerlMagick-6.86.tar.gz
-> OK
Unpacking PerlMagick-6.86.tar.gz
Entering PerlMagick-6.86
META.yml/json not found. Creating skelton for it.
Configuring PerlMagick-6.86
Running Makefile.PL
################################### WARNING! ###################################
# It seems that you are trying to install Perl::Magick on a MS Windows box with
# perl + gcc compiler (e.g. strawberry perl), however we cannot find ImageMagick
# binaries installed on your system.
#
# Please check the following prerequisites:
#
# 1) You need to have installed ImageMagick Windows binaries from
# http://www.imagemagick.org/script/binary-releases.php#windows
#
# 2) We only support dynamic (DLL) ImageMagick binaries
# note: it is not possible to mix 32/64-bit binaries of perl and ImageMagick
#
# 3) During installation select that you want to install ImageMagick's
# development files (libraries+headers)
#
# 4) You also need to have ImageMagick's directory in your PATH
# note: we are checking the presence of convert.exe and/or identify.exe tools
#
# 5) You might need Visual C++ Redistributable Package installed on your system
# see instructions on ImageMagick's Binary Release webpage
#
# We are gonna continue, but chances for successful build are very low!
################################################################################
Checking if your kit is complete...
Looks good
Note (probably harmless): No library found for -lMagickCore-6.Q16
Writing Makefile for Image::Magick
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have ExtUtils::MakeMaker 0 ... Yes (6.62)
Building and testing Image-Magick-6.86
cp Magick.pm blib\lib\Image\Magick.pm
AutoSplitting blib\lib\Image\Magick.pm (blib\lib\auto\Image\Magick)
C:\Dwimperl\perl\bin\perl.exe C:\Dwimperl\perl\lib\ExtUtils\xsubpp -typemap C:\Dwimperl\perl\lib\ExtUtils\typemap -typemap typemap Magick.xs > Magick.xsc && C:\Dwimperl\perl\bin\perl.exe -MExtUtils::Command -e mv -- Magick.xsc Magick.c
gcc -c -s -O2 -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -mms-bitfields -s -O2 -DVERSION=\"6.86\" -DXS_VERSION=\"6.86\" "-IC:\Dwimperl\perl\lib\CORE" -D_LARGE_FILES=1 -DHAVE_CONFIG_H Magick.c
Magick.xs:60:31: error: magick/MagickCore.h: No such file or directory
Magick.xs:167: error: expected specifier-qualifier-list before 'MagickRealType'
Magick.xs:188: error: expected specifier-qualifier-list before 'ImageInfo'
Magick.xs:210: error: 'MagickNoiseOptions' undeclared here (not in a function)
however we cannot find ImageMagick binaries installed on your system.
Is ImageMagick is in your path, as recommanded in the 4) point? Open cmd.exe and type convert -v or convert.exe -v. If you don't see informations about Image Magick (Windows have a built-in convert command), it is very likely you have to add it to your path.
You also have to check points 1), 3), and 5). After that try again to run installation process through cpanm.
Trying to install for Citrus Perl, I discovered on debugging through the Perl part of the install that the mingw64 install had not included 'pexports.exe'. Downloading that from https://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/
and placing it in the mingw64 directory was necessary to solve the problem of a long list of library export symbols not found.
Prior to that I had also set the environment variables CPATH, C_INCLUDE_PATH, and CPLUS_INCLUDE_PATH to point to the "include" directory of the ImageMagick install include directory in C:\Program Files (x86). (When you install ImageMagick you should check the box to install also for Strawberry Perl.)

Resources