Can't get Cabal-install to work on my mac - cabal

So, I'm trying to get cabal installed so I can get quickcheck to work in haskell, but nothing seems to work. Whenever I try to run "cabal-install" in my terminal (on mac) I get the same message "command not found", I've looked at multiple different "solutions" and even "solutions" on the cabal website, but nothing seems to work. Any help at all would be much appreciated

cabal-install is a package. cabal is the executable/command installed by the cabal-install package. cabal install is a subcommand of the cabal command—it's the command cabal called with the argument install. Your full command "should" be cabal install QuickCheck, but there's no point in actually executing that command. If you have Cabal v1 or v2, cabal install refers to the version 1 install method, which is broken and dangerous. If you have Cabal v3, cabal install refers to the version 2 install method, where cabal install QuickCheck is pointless. It will install QuickCheck, but QuickCheck is just a library with no executables, so there's no point.
Assuming cabal-install is correctly installed (you should have access to the cabal command), you need to figure out what you're going to do with QuickCheck. If you just want to open a GHCi session, say cabal v2-repl -b QuickCheck. If you want to compile a bunch of files (i.e. you want something more "permanent"), you need to create a package, where the <pkgname>.cabal file contains something along the lines of
build-depends: base, QuickCheck, ..etc
When you build such a package with cabal v2-build, or you start GHCi with cabal v2-repl -b QuickCheck, cabal will go and install QuickCheck automatically if it needs to. This is why cabal v2-install QuickCheck is pointless.

Related

Error when trying to do (sudo apt install flex bison): The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt [duplicate]

I was watching this, and, as you can see, the first command I am told to put in is:
sudo apt-get install python-setuptools
When I do this, it outputs:
sudo: apt-get: command not found
I have no idea why this is the case.
How can I resolve this so I am following the tutorial correctly?
Mac OS X doesn't have apt-get. There is a package manager called Homebrew that is used instead.
This command would be:
brew install python
Use Homebrew to install packages that you would otherwise use apt-get for.
The page I linked to has an up-to-date way of installing homebrew, but at present, you can install Homebrew as follows:
Type the following in your Mac OS X terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
After that, usage of Homebrew is brew install <package>.
One of the prerequisites for Homebrew are the XCode command line tools.
Install XCode from the App Store.
Follow the directions in this Stack Overflow answer to install the XCode Command Line Tools.
Background
A package manager (like apt-get or brew) just gives your system an easy and automated way to install packages or libraries. Different systems use different programs. apt and its derivatives are used on Debian based linux systems. Red Hat-ish Linux systems use rpm (or at least they did many, many, years ago). yum is also a package manager for RedHat based systems.
Alpine based systems use apk.
Warning
As of 25 April 2016, homebrew opts the user in to sending analytics by default. This can be opted out of in two ways:
Setting an environment variable:
Open your favorite environment variable editor.
Set the following: HOMEBREW_NO_ANALYTICS=1 in whereever you keep your environment variables (typically something like ~/.bash_profile)
Close the file, and either restart the terminal or source ~/.bash_profile.
Running the following command:
brew analytics off
the analytics status can then be checked with the command:
brew analytics
As Homebrew is my favorite for macOS although it is possible to have apt-get on macOS using Fink.
MacPorts is another package manager for OS X:.
Installation instructions are at The MacPorts Project -- Download & Installation after which one issues sudo port install pythonXX, where XX is 27 or 35.
Conda can also be used as package manager. It can be installed from Anaconda.
Alternatively, a free minimal installer is Miniconda.
apt-get command is only available on Debian or Debian-based Linux distributions (such as Ubuntu, Linux Mint, Kali). It is not accessible on macOS. Alternatively, you can use package managers like Homebrew, MacPorts, and Nix. You can find equivalent commands for each as follows
brew install package_name
sudo port install package_name
nix-env -i package_name
Before installing above package managers, you need to install XCode first. Follow the operation instructions from this guide How to Fix "sudo apt-get command not found" Error on Mac Terminal.
Alternatively You can use the brew or curl command for installing things, wherever apt-get is mentioned with a URL...
For example,
curl -O http://www.magentocommerce.com/downloads/assets/1.8.1.0/magento-1.8.1.0.tar.gz

remove downloads from cabal installation

I wanted to install Idris, so I first installed Haskell and then wrote cabal update and cabal install idris in the terminal. However, after downloading and installing lots of components, the installation finally failed on some packages. I then did the installation via the Windows-.exe from idris-lang.org and now it runs fine, but I want to remove what was downloaded and installed before with the cabal command. Any idea how to do that? Is there such a command like "cabal deinstall idris" or something? Or would it affect the other installation too?

Haskell platform on mac installs cabal in /usr/bin, but cabal install goes in ~/Library/Haskell

I’ve just installed the Haskell Platform on my Mac running Mavericks 10.9. The cabal version included (1.16) is out of date, and prompts me to run “cabal update” and then “cabal install cabal-install". Doing so installs cabal 1.20.0.3, but it installs in ~/Library/Haskell. This is not in my executable path, so further attempts to run cabal result in executing version 1.16 from /usr/bin, which was not updated.
I guess I could get around this by changing my executable path to include ~/Library/Haskell, with higher preference than /usr/bin. But I don’t really want to do this. And I don’t want to maintain multiple out of date versions of the software in hidden locations on my system. How do I get cabal to update the executable in the right place? Running with sudo did not help.
Edit: Updated my path, but somehow it still doesn’t work:
[76 of 76] Compiling Main ( Main.hs, dist/build/cabal/cabal-tmp/Main.o )
Linking dist/build/cabal/cabal ...
Warning: No documentation was generated as this package does not contain a library. Perhaps you want to use the --executables flag.
Installing executable(s) in
/Users/lethe/Library/Haskell/ghc-7.6.3/lib/cabal-install-1.20.0.3/bin
Installed cabal-install-1.20.0.3
Updating documentation index /Users/lethe/Library/Haskell/doc/index.html
euclid:Public lethe$ which cabal
/Users/lethe/Library/Haskell/bin/cabal
euclid:Public lethe$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library
euclid:Public lethe$ echo $PATH
/Users/lethe/Library/Haskell/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin
It claims it installed cabal 1.20.0.3 to ~/Library/Haskell, and since the path is updated, it claims it’s going to execute the version in ~/Library/Haskell, but it also claims the executed version is 1.16.0.2. What’s going on here?
I also tried ghc-pkg recache and cabal install cabal-install-1.20.0.3 (with version number specified), but executed version is still 1.16.0.2
There are a couple of solutions:
1) Try updating the PATH variable such that it looks in your local path first.
(Add this to your .bash_profile: export PATH=$HOME/Library/Haskell/bin:$PATH. Source the profile and then retry the whereis command to identify which binary you are using, it should use your local one)
Though this didn't work for me. I had to resort to the next step to make it work:
2) Brute force fix: Delete /usr/bin/cabal.
Hope this helps.
According to 23skiddo at GitHub, the way to get cabal to install in the system-wide directory is cabal install --global. Also if your shell is executing the wrong path to an executable you probably need to clear the cache with hash -d cabal or hash -r.
I once had an alias to a command and forgot about it. That is not picked up by "which ".
Try $(which cabal) --version. If it shows 1.20 there may be some similar problem. Use compgen -a to list your aliases.
/Users/lethe/Library/Haskell/ghc-7.6.3/lib/cabal-install-1.20.0.3/bin also is not /Users/lethe/Library/Haskell/bin.
Also:
There is a new Haskell-Plattform release 2014.2 now. This comes with Cabal 1.18 and GHC 7.8.3.
It updates easily to Cabal 1.20 (I don't know why it does not come with 1.20 in the first place).
I already tried many different setups between using Haskell-Plattform, Homebrew ghc + haskell-plattform and also http://ghcformacosx.github.io/
Last one makes most sense to me after trying all different ways to use Haskell on OSX.
If you switch between different "distributions" make sure you really get rid of "everything" that is installed from other versions of Haskell.
I think the most important thing is to recognize that all of those installations are more or less the same. It just moves paths and preferences around.

Cabal never updates

I'm trying to update Cabal on OSX (with ghci 7.8.2 installed), so I run the following commands
cabal update
cabal install cabal-install
To get it up to date, and the installation seems to complete with no errors. However, when I run cabal update again, it still says that I'm not up to date and to run cabal install cabal-install again.
I've read that I might have to do something to make the new version of Cabal have precedence over the one installed with Haskell, but I have no idea how to do this.
Turns out I needed to add /Users/username/Library/Haskell/bin
to $PATH to get the latest version to be used.

cabal-install "Couldn't read cabal file ..."

I just made a fresh haskell-platform install on a Linux Mint 12, via apt-get. Everytime I try to install some hackage package with cabal-install, I get a:
couldn't read caba file xxxx.cabal
where xxxx is a dependency of the package I'm installing or the package itself. Based on this thread on haskell cafe and other questions here in SO, I deleted the bytestring package from the index:
tar -f ~/.cabal/packages/hackage.haskell.org/00-index.tar --delete bytestring/0.9.2.0
tar -f ~/.cabal/packages/hackage.haskell.org/00-index.tar --delete bytestring/0.9.2.1
but the errors are still there.
My cabal-install version is:
$ cabal --version
cabal-install version 0.10.2
using version 1.10.1.0 of the Cabal library
The error is like this:
$ cabal install yesod
Resolving dependencies...
cabal: Couldn't read cabal file "fsnotify/0.0.5/fsnotify.cabal"
Does anyone knows what might be happening?
I'm having the same problem. There's a relevant mailing list thread about this problem at http://haskell.1045720.n5.nabble.com/Cabal-install-fails-due-to-recent-HUnit-td5715081i20.html
I believe the upshot is that the format of the packages files has changed, and the cabal version in use here (I have the same version, obtained from ubuntu oneiric) can't understand the files. You can't even do "cabal install cabal-install".
The mailing list thread just peters out in september 2012 without a clear decision being made, but I think they decided to just ignore the problem. There's not a clear statement of what to do for users like us; I think the only approach possible is to install haskell from scratch, but I don't yet know where to start with that.
EDIT: I fixed this by downloading the latest source package of cabal from http://hackage.haskell.org/packages/archive/cabal-install/1.16.0.2/cabal-install-1.16.0.2.tar.gz, unpacking it and following the instructions in its README to do a local install.
I was having the same problem and I wasn't able to follow Richard's instructions, so I realized I was running version 7.0.?, I uninstalled it using the command $ uninstall-hs, then installed the newest version (7.6.3). Problem solved here.

Resources