How do I install Haskell Stack on Mac? - haskell

I have followed the instructions to install ghcup on my MacOS by following command:
curl https://get-ghcup.haskell.org -sSf | sh
But I couldn't install it, it prompted errors like these:
Failed to install, consider updating this script via: ghcup upgrade
"ghcup --cache install" failed!

stack and ghcup are two different tools.
You can get stack from this website, which involves running the following command:
curl -sSL https://get.haskellstack.org/ | sh
On the other hand, ghcup is a tool that only installs the Haskell compiler (GHC), which means that you won't be able to build a project using Stack. Note that this last installation comes with a build tool called cabal. You can learn the differences between stack and cabal in this other question.
Regarding your error with ghcup, I'd try to use the instructions from https://gitlab.haskell.org/haskell/ghcup. It is the main repo from the project, and probably updated faster. Note that you can use the "simple bootstrap" process, and if that doesn't work, try the manual one.

If you have brew installed, you can use : brew install stack

Related

cabal install ghc impossible happened: heap overflow

I'm trying to follow along with the Plutus Pioneer lectures, and I'm getting this error
My system:
Ubuntu Linux Docker image running on MacOS.
I installed the Haskell package on the image from here: https://www.haskell.org/platform/linux.html
using this line in my Dockerfile: RUN apt-get install -y haskell-platform
This seems to install Cabal version 2.4.
When I clone the code repository for the lectures: https://github.com/input-output-hk/plutus-pioneer-program and then go to the week01 directory and try cabal build like in the lecture, I get dependencies not found errors. The first missing dependency is 'aeson', which seems to install if I run cabal install aeson.
The subsequent build attempts fail on dependency 'base' being the wrong version.
Then I thought maybe if I update Cabal to version 3.4 it might help, so I tried cabal install cabal-install, but this also has errors:
Theexception was:ExitFailure (-9)
This may be due to an out-of-memory condition.
So I googled some more and tried this command line: cabal install --ghc-options="+RTS -M600M" -j1 cabal-install from here https://stackoverflow.com/a/46148345/52236
This seems to get further, but now I'm at this error:
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.5 for x86_64-unknown-linux): heap overflow
If anyone has any idea how to fix this it would be appreciated. Do I need to add more RAM to my Docker Ubuntu image? It currently has 1.9GB of memory and 1.7GB free.
thanks,
m
I fixed this by increasing the RTS param:
cabal install --ghc-options="+RTS -M1000M" -j1 cabal-install
Well, actually it compiled everything, but cabal --version still says 2.4, not 3.4. There was this warning too:
Warning: could not create a symlink in /root/.cabal/bin for cabal because the
file exists there already but is not managed by cabal. You can create a
symlink for this executable manually if you wish. The executable file has been
installed at /root/.cabal/bin/cabal

How to install older gcc package using APT from a repository?

I have GCC v9. But I'm trying to install a GCC 4.8.1 version to test a library compilation on that very old version of GCC.
The version is not available in the official Ubuntu repos,it is deprecated, but I've found it in other mirrors as told by the official GCC website. This one seems like popular one:
https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
I have very little knowledge of linux package systems except for the basic. I want to keep both versions. So I should do this:
sudo apt -y install gcc-4.8.1 gcc-9
The reason why I want to use this command and not install it from the file, apart from the difficulty of doing that for me, is that I'm following a guide in order to have several GCCs on my system:
https://www.fosslinux.com/39386/how-to-install-multiple-versions-of-gcc-and-g-on-ubuntu-20-04.htm
When I add the url to the sources.list file seems like it is working.
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update -q
But when I try to call the install with gcc-4.8.1 or gcc-4.8 , or even gcc-4 the package doesn't exist.
Package gcc-4.8 is not available, but is referred to by another
package. This may mean that the package is missing, has been
obsoleted, or is only available from another source E: Package
'gcc-4.8' has no installation candidate
Also, I don't know if websites like these can be added to the repos list in order to find the package using APT:
http://www.netgull.com/gcc/releases/gcc-4.8.1/
[EDIT]
I downloaded the package from the website I linked. I have no idea how to install this by hand. If only I could find a repository that could help me with this... I have no idea how to make APT help me with the installation.
But I'm trying to install a GCC 4.8.1 version to test a library compilation on that very old version of GCC.
Developers have tools up their sleeve so they don't have to install dependencies and bloating their systems for every library (and every configuration of that library!) they want to try out and test.
Use docker. You could write for example a testing script, assuming your project uses make:
# test_my_lib_in_gcc-4.8.sh
#!/bin/sh
docker run -ti --rm -v $PWD:/project -w /project gcc:4.8 -u $UID:$GID sh <<EOF
make && make test
EOF
that will compile and test your application in using 4.8 gcc. Consider how easy it is to change gcc version - just change the number. You could test your library in gcc, in different versions, and using other compilers and on different distributions to make sure it works for others. If you're a developer of the library, write an automatized CI pipeline that would automatically test your application each commit in specific docker environment, using ex. https://docs.gitlab.com/ee/ci/README.html or https://travis-ci.org/ .

Couldn't install ghcup installer for Haskell on my MacOS machine

Currently, I'm trying to learn pure functional programming language, which is Haskell. I'm trying to install Haskell compiler, I have followed the instructions to install ghcup on my MacOS by following command:
curl https://get-ghcup.haskell.org -sSf | sh
But I couldn't install it, it prompted errors like these:
Following commands are required, but missing, please install: xz
"ghcup upgrade" failed!
Following commands are required, but missing, please install: xz
I hope somebody picks up this question and helps me get this out, thanks a lot.
xz [wiki] is a (de)compression tool. It is sometimes used to send data in a compressed form over a network.
You can install xz on a Mac OS X system with:
brew install xz
Given of course you first installed brew on your machine [brew.sh].

Facebook Duckling error getDirectoryContents:openDirStream: does not exist

i followed the following steps:
apt-get install haskell-platform
curl -sSL https://get.haskellstack.org/ | sh
git clone https://github.com/facebookincubator/duckling.git
stack setup
stack build
stack exec duckling-example-exe
and i get the following error any idea why?
duckling-example-exe: /usr/share/zoneinfo/: getDirectoryContents:openDirStream: does not exist (No such file or directory)
You might just need to apt-get install tzdata -- I was searching for where zoneinfo is supposed to come from, and I found reports that it was not installed by default anymore in Ubuntu 16.04. I don't see that it's a part of baseimage at all, so it's probably missing from your container.
from source

Cannot successfully install plot Haskell

I'd like to do some graphing in my Haskell program, but when I try to install plot I get the following error.
Preprocessing library plot-0.2.3.4...
lib/Graphics/Rendering/Plot/Figure/Simple.hs:37:8:
Could not find module ‘Numeric.Container’
Use -v to see a list of the files searched for.
lib/Graphics/Rendering/Plot/Types.hs:25:8:
Could not find module ‘Data.Packed.Vector’
Use -v to see a list of the files searched for.
lib/Graphics/Rendering/Plot/Types.hs:26:8:
Could not find module ‘Data.Packed.Matrix’
Use -v to see a list of the files searched for.
cabal: Error: some packages failed to install:
plot-0.2.3.4 failed during the building phase. The exception was:
ExitFailure 1
Following this issue I updated hmatrix to version 0.17.0.1 but still get the same error. Any ideas?
Are you managing the project with cabal, or are you just installing into the global package space?
I would move to either using cabal or stack to manage the dependencies.
FWIW I've verified that plot-0.2.3.4 will compile with hmatrix-0.16.1.5 using the stack resolver lts-3.7 so I don't think it's a problem with hmatrix.
If you are using cabal, post your cabal file and we can figure out how to make it work. Otherwise, I would recommend creating a stack project, eg.
run stack new project-name
edit project-name.cabal and add plot to the build-depends: fields
run stack build
Configuring hmatrix-0.16.1.5...
setup-Simple-Cabal-1.22.4.0-x86_64-linux-ghc-7.10.2: Missing dependencies on
foreign libraries:
* Missing C libraries: blas, lapack
Found the libblas library I needed via:
sudo apt-cache search blas | grep dev
from: https://github.com/albertoruiz/hmatrix/blob/master/INSTALL.md#linux
sudo apt-get install libblas-dev libgsl0-dev liblapack-dev libatlas-base-dev
setup: The pkg-config package 'cairo' version >=1.2.0 is required but it could
not be found.
After some putzing around on the wiki pages for gtk2hs
sudo apt-get install libghc-gtk-dev
Now it should install successfully.
stack install plot
Intermediate errors are from me re-attempting stack install plot. These instructions assume Ubuntu 14.04 but you can translate what packages you need to Mac OS X / Windows.
As the other poster said, this was with the 0.16 version of hmatrix.

Resources