Installing Haskell with Homebrew fails - haskell

I had installed Haskell before, but that was hopelessly outdated. I tried to uninstall everything based on the documents I found and reinstalled it using homebrew.
brew install ghc cabal-install
This succeeded
==> Downloading https://homebrew.bintray.com/bottles/ghc-7.10.1_1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ghc-7.10.1_1.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/ghc/7.10.1_1: 5423 files, 821M
==> Downloading https://homebrew.bintray.com/bottles/cabal-install-1.22.2.0.yosemite.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring cabal-install-1.22.2.0.yosemite.bottle.1.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
🍺 /usr/local/Cellar/cabal-install/1.22.2.0: 6 files, 19M
But then I get this:
> ghci
-bash: /usr/bin/ghci: No such file or directory
And
> cabal
-bash: /usr/bin/cabal: No such file or directory
Since I can run other packages that are in my Cellar, I would think that I should be able to run these packages as well?

I think you have some lingering symlinks or similar in /usr/bin. Homebrew automatically symlinks binaries from its "cellar" to /usr/local/bin (notice that the directory includes local).
A reasonable course of action for you might be
Check if Homebrew installed ghc, cabal, etc in /usr/local/bin (they should be symlinks pointing to somewhere under /usr/local/Cellar/). If they do exist you can conclude that Homebrew did not screw up.
Check what kind of thing /usr/bin/ghci, /usr/bin/cabal actually are: eg ls -l /usr/bin/ghci. It will probably tell you that they are symlinks which point to files that don't exist, they are probably left from your previous Haskell installation.
Remove the broken symlinks and make sure that /usr/local/bin is somewhere on your $PATH.
(Now there have been people who do not recommend installing GHC using Homebrew, you might want to try the installation instructions found on the Haskell homepage: https://www.haskell.org/downloads. On the other hand I don't see anything too strange in Homebrew's GHC formula, so it might be fine currently.)

Related

Reinstall python packages after homebrew python#3.8 update

I have recently updated python to python#3.8 via homebrew.
I then noticed that my python scripts were unable to link to the global python packages that I had previously installed with pip (packages installed globally and not within a virtual environment).
This has sent me down the rabbit hole of understanding how python is set up on macos and I have several questions.
pip installed by homebrew will now install all packages in /usr/local/lib/python3.8/site-packages.
Does that mean I need to reinstall all my python packages that used to live (and still are) in /usr/local/lib/python3.7? Should I remove the latter directory after? (For that matter I can see I have also a /usr/local/lib/python3.6 directory)
What's the efficient way of managing this in the future when the next python update comes along? Virtual envs per project (I'm not very familiar with the use of virtual envs)?
When I run
brew list | grep python I get the following list
python
python3
python#3.8
I can see python#3.8 is correctly symlinked as /usr/local/bin/python3 but I don't know what the python and python3 in the above list are since looking at /usr/local/Cellar I can see that I have an empty /usr/local/Cellar/python directory and a /usr/local/Cellar/python3 directory that is symlinked to it. Can I juste remove these two folders?
Finally, looking into all this, I was surprised to discover a python3 executable living in /usr/bin.
Looking into the sys.path when I execute /usr/bin/python3, I can see it's some sort of python installed by Xcode since it's looking for libraries in various Xcode.app directories.
Since my /usr/local/bin is at the top of my PATH envt variable, this python3 will never be called but I wonder why I'd need it at all and whether I can just get rid of it.
I suppose the answer to a lot of these questions is to use virtual environments, which I've miraculously avoided doing for so long... Would love some help understanding the above though.
EDIT: Running brew info python or brew info python3 returns the same thing
python#3.8: stable 3.8.3 (bottled)
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python#3.8/3.8.3_2 (4,268 files, 65.5MB) *
Poured from bottle on 2020-07-12 at 23:19:08
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/python#3.8.rb
I had a similar issue with a system running Python 3.9
I had initially not run the final command (only the --dry-run), as everything seemed fine, but as suggested during the installation, using brew link to clobber and create new symlinks was needed.
% brew link --overwrite --dry-run python#3.9
Would remove:
% brew link --overwrite python#3.9
Linking /usr/local/Cellar/python#3.9/3.9.1_1... 23 symlinks created
%
As suggested by MisterMiyagi in the comments, this was uncovered via brew doctor
...
Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
python#3.9

How to install smlnj in arch linux?

Earlier I was in Ubuntu & it was easy to install smlnj using
apt-get install smlnj
but now I shifted to Arch & I'm finding it difficult to install smlnj.
I tried to find smlnj package through yaourt but I didn't found any.
Then I tried to install it by steps given in official site by downloading tar file. I followed given steps and extracted tar file in /usr/local/sml & then compiled by running command
config/install.sh.
After doing all this I tried to run sml but was not successful. I tried setting environment variable but again was not successful.
Please tell me whether I'm missing any steps or doing it wrong way. What is correct way to install smlnj in Arch Linux?
Update: As Alexander (xyproto) points out, pacman -S smlnj should work again now that SML/NJ is in the [multilib] repository. The solution below would still work, but credit for making installation more convenient should go to him. :-)
Before: It seems that the package became unavailable for x86_64 in Feb 2017, but it doesn't look like it should have happened. I've asked Alexander who maintains the package in [community].
The AUR doesn't contain an smlnj package because it's against AUR policy to overlap with official packages, unless the AUR package is compiled with some tweak that is clearly visible in the package name.
You can still build an Arch package and install that by finding the PKGBUILD and accompanying files at: https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/smlnj (or by cloning the git repo below with those four files in it):
~ $ git clone https://github.com/sshine/smlnj-arch.git
~ $ cd smlnj-arch
~/smlnj-arch $ makepkg
~/smlnj-arch $ sudo pacman -U smlnj-110.80-3-x86_64.pkg.tar.xz

How do I restore my Haskell setup to the bare Homebrew configuration?

I have a system setup of Haskell that I've maintained with Homebrew and subsequent cabal install invocations for various packages. I would like to take this back to the bare installation created with brew install haskell-stack.
How do I do this? Right now I seem to have a bunch of stuff lying around (e.g. old docsets, executables like ghc-mod etc.) at the system level, even after deleting all installed packages with rm -r ~/.ghc. Is there a reliable way to get back to the basic configuration that brew install haskell-stack creates?

downgrade chef-client version 11

trying to downgrade chef-client. enclosed a snippet:
$ chef-client --version
Chef: 11.10.4
$ curl -sL https://www.opscode.com/chef/install.sh | sudo bash -s -- -v 11.8.2
Downloading Chef 11.8.2 for ubuntu...
downloading https://www.opscode.com/chef/metadata?v=11.8.2&prerelease=false&nightlies=false&p=ubuntu&pv=12.04&m=x86_64
to file /tmp/install.sh.1934/metadata.txt
trying wget...
url https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef_11.8.2-1.ubuntu.12.04_amd64.deb
md5 3d3b3662830a44eeec71aadc098a4018
sha256 a5b00a24e68e29a01c7ab9de5cdaf0cc9fd1c889599ad9af70293e5b4de8615c
downloaded metadata file looks valid...
downloading https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef_11.8.2-1.ubuntu.12.04_amd64.deb
to file /tmp/install.sh.1934/chef_11.8.2-1.ubuntu.12.04_amd64.deb
trying wget...
Comparing checksum with sha256sum...
Installing Chef 11.8.2
installing with dpkg...
(Reading database ... 107385 files and directories currently installed.)
Preparing to replace chef 11.8.2-1.ubuntu.12.04 (using .../chef_11.8.2-1.ubuntu.12.04_amd64.deb) ...
Unpacking replacement chef ...
Setting up chef (11.8.2-1.ubuntu.12.04) ...
Thank you for installing Chef!
$ chef-client --version
Chef: 11.10.4
also tried rebooting the machine, though there result is the same.
can it be done, can chef-client be downgraded?
If you installed Chef 11.10.4 from the omnibus installer (basically the same install.sh you are using for the older version) then you basically got a self-contained installation of Chef inside /opt/chef.
Removing that directory will remove almost all traces of the old install. All that is left is to remove the symlinks inside /usr/bin, which will probably be chef-client, chef-solo, chef-shell, knife, ohai and maybe a few others (look for symlinked files in /usr/bin that point to /opt/chef.
After that, reinstall using your above technique and you should have the correct version installed.
Just install specific version from https://downloads.chef.io/chef (depends on your OS). I succeeded to downgrade my chef-client version with simple installation that override the newer one.

cabal install bnfc missing directory

I'm new to Haskell, trying to write a program for compiler construction class.
I installed the haskell-platform package on my ubuntu 13.10, and then (without messing around with anything after installing haskell platform) tried to run the following command:
$ sudo cabal install bnfc
which results with:
Resolving dependencies...
Configuring BNFC-2.6.0.3...
cabal: The following installed packages are broken because other packages they
depend on are missing. These broken packages must be rebuilt before they can
be used.
package process-1.1.0.2 is broken due to missing package
directory-1.2.0.1-508733a890139bbedb8aa76468431462
Failed to install BNFC-2.6.0.3
cabal: Error: some packages failed to install:
BNFC-2.6.0.3 failed during the configure step. The exception was:
ExitFailure 1
As I try installing package directory it says the package is already installed.
Can anyone help?
I also am using Ubuntu 13.10 with the haskell platform package, and bnfc installs for me.
There are a few things you can check....
Don't use sudo with cabal install (by default cabal installs packages in your own home directory, using sudo might be causing trouble by giving the wrong file ownerships, or perhaps trying to put files in /root, or even overwriting /usr stuff)
Rename ~/.cabal/ and ~/.ghc/, and rebuild them by running "cabal update" (You may need to re-add ~/.cabal/bin/cabal from the moved location after the move). These hold installed packages and their info.... Since you have a new vanilla install, these should basically be empty, although the meta info in them may be corrupt. (if for some reason this makes things worse, you can always restore the original directory.... If it solves the problem, you can delete the original .cabal and .ghc)
You can get more info about why a package isn't installing by doing the following
cabal unpack bnfc #This will download and unpack the source code
cd BNFC-2.6.0.3 #enter the newly created source directory
cabal configure #This checks that all system dependencies are met
cabal build #This builds the package
cabal install #This installs the package in ~/.cabal/
(You may have to iterate to another package if a dependency isn't met)
I think 2. may solve your problem, as the error message you showed implies that the build process is hooked on finding a very specific version of the directory package, rather than the latest one. This happened to me once and cleaning out .cabal solved the problem for me.

Resources