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

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.

Related

Could not perform backup protocol version exchange, error code -1

I need to backup iphone with libimobiledevice, using ubuntu, the device is detected but going to launch the backup commands the following error is displayed:
Started "com.apple.mobilebackup2" service on port 49343.
Could not perform backup protocol version exchange, error code -1
What could it depend on?
Several Github issues have reported this problem, like this one.
Solution:
you need to use latest version of idevicebackup and libimobiledevice
Indeed, if you use Ubuntu 20.04 (for instance), the libimobiledevice package is outdated, as of now.
If that's your case, you'll have to either wait for the next Ubuntu release (22.04) or compile it from source, what may become necessary at some point after the release of Ubuntu 22.04 anyway.
Disclaimer: downside of compiling yourself is that your binaries are not managed by the package manager. You'll have to update yourself, git pulling or downloading the newest source code releases and re-compiling everything everytime. You might have to redo all of this after a distribution upgrade. Upside is that your binaries do work...
Note: compilation steps are described on the official site only for debian; I could perform them equally well on a Linux Mint 20.3 (based on Ubuntu, based on debian). OP does not mention the OS he or she uses, but debian based seem to be the only ones available for now, so what follows should work on debian based OSes.
Compilation from source, step by step:
uninstall the official package and its dependencies and:
install the build dependencies: sudo apt install build-essential checkinstall git autoconf automake libtool-bin libplist-dev libusbmuxd-dev libssl-dev usbmuxd (see "from source" here)
get libimobiledevice source code from its repo, using for instance git clone https://github.com/libimobiledevice/libimobiledevice.git. You might get to the releases page and use the latest tar.gz instead (1.3 at the moment).
also get source code of other libraries required by libimobiledevice: libplist, libimobiledevice-glue and libusbmuxd. (I also compiled usbmuxd instead of using the official package, but I am not sure it is necessary). For each one of them, you can git clone it or download and untar the latest source code release, if available.
choose a prefix directory, where libraries and binaries will go. Create it if necessary (official libimobiledevice site suggests /opt/local and I will use this too in the next steps; in order for the compilation to work, you'll have to sudo mkdir /opt/local and export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig before starting the first compilation)
to compile and install, cd to the root of each git-cloned (or source-downloaded) directory (in this order: lipblist, libimobiledevice-glue, libusbmuxd and libimobiledevice, because each one depends on the previous one) and execute, in each one of them: ./autogen.sh --prefix=/opt/local, then make and finally sudo make install. (Note, the autogen line for libimobiledevice may be ./autogen.sh --prefix=/opt/local --enable-debug, as suggested here).
Having done all of this, the iphone was not mounted automatically, I had to manually run idevicepair pair and then could mount it using ifuse ./iphone_mount_point/ (do sudo apt install ifuse if necessary) and perform a backup using idevicebackup2 backup --full iphone_backup/. Read the help of idevicebackup2 for more information.

Not able to find glib.h in fedora 16

I am new to fedora (Linux). Just installed glib packages using yum install glib*. But still not able to compile.
I used locate to find where the pkg-config file is. I opened all of these but could not find PKG_CONFIG_PATH environment variable. Any help? :)
pkg-config files are stored in /usr/lib64/pkgconfig/* or /usr/lib/pkgconfig/* (depending on whether you're on 64-bit or 32-bit).
The glib package contains glib 1.x, for glib 2.x the right package is glib2 (backwards-incompatible API changes require a new package).
Furthermore, development headers, documentation, pkg-config files, etc., are provided in a separate package, which is usually called '$packagename-devel'. This split allows you avoid installing all the development stuff if all you want to do is use the library. So, what you really want is yum install glib2-devel.
Note that, since you know the pkg-config name, you can just do yum provides '*/glib-2.0.pc' (or provide the full path and you'll only get a single result) to find the packages which provide the glib-2.0 pkg-config file. With dnf you can also just do something like dnf install '/usr/lib64/pkgconfig/glib-2.0.pc', not sure if the version of yum from F16 can do the same or not, which brings me to…
Fedora 16 is way too old. Unless you have a very good reason for using this specific version of Fedora, stop doing so. Beyond being a much less pleasant experience, Fedora 16 is old enough that it is no longer receiving security updates. If you need to use something from that era you should find something that is still supported (RHEL 6 is based of F12, RHEL 7 is based on F19, you can use CentOS if you don't want to pay for support).

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.

(Mac OSX) Adding libraries to C -specifically gnuplot

I am a begineer trying to get code in C. I am working on a Mac and using xcode. My only past experience has been with java using eclipse and everything was pretty straight forward. I have almost no experience with terminal.
I am required to learn a bit of C for a project I will be working on and the learning of syntax is coming along okay, but I am at a point where I need to include some libraries in my c program. Specifically I am attempting to make plots with gnuplots.
I have downloaded gnuplot-4.6.3 from their repository and I do not even know how to install the files. I have been looking around and have tried using terminal to use the ./configure command when I am in the gnuplot-4.6.3 directory. But I really don't know what I am doing so I don't even know where to go next or what to do next.
Sorry if this is so trivial, I honestly just have never done this before and I cannot find a good tutorial on what to do.
Thanks for any help you can offer.
I would recommend using MacPorts for installing third-party tools and libraries. It knows the dependencies required and will install them as part of the installation.
Download it from macports.org.
Install it, and allow it to modify your ~/.profile so that /opt/local/bin is in your $PATH (any issue then just do export PATH=/opt/local/bin:$PATH from the command line).
sudo port selfupdate
sudo port install gnuplot
Now that will install the library into /opt/local/lib with the include files in /opt/local/include, so now just add that library to your Xcode project. Select the target and in the Build Phases tab open up the Link Binary With Libraries and press the + button and select Add Other. Now find /opt/local/lib/libgnuplot.a (I am assuming that's what it's called; I don't have it installed my self):
Now add /opt/local/include to your Header Search Paths so the compiler can find the gnuplot header files. Select the target and in Build Setting type in "header search" in the search box. Now double-click on the Header Search Path in the target column (or the project column to the right) and add /opt/local/include:
It's fine! You're learning then! Keep up! When I hit this kind of problem you may want to learn about the basis for linux gcc/g++ compilation and linking processes. Then you should learn Cmake and Automake, which are basically packages to configure projects before compiling building.
A typical (good) project in Unix systems build with commands
./configure
make
sudo make install
or
cmake CMakelists.txt
make all
sudo make install
That's what you need to do after downloading a source tarball online to install unix programs.
Now since you are using Mac, there are so-called package installers, one which is macports and homebrew. I personally suggest homebrew than macports here (I've tried both, although macports still outnumber homebrew with the number of repos, homebrew has the newest support, especially when upgrading to a new OS). So to install homebrew you can do
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Execute that in your terminal (see http://brew.sh/) for more information.
Then you could simply install GNUplot by
brew install gnuplot

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