Not able to initialize sandbox using cabal on haskell platform - haskell

I have done the below steps to install cabal . I have already installed haskell platform using sudo apt-get install haskell-platform
http://coldwa.st/e/blog/2013-08-20-Cabal-sandbox.html
Building Cabal from git
Assuming you already have a previous version of cabal installed:
$ git clone git://github.com/haskell/cabal.git /path/to/cabal
$ cd /path/to/cabal
$ cabal install Cabal/ cabal-install/
However when I try to initialize a sandbox, it throws error as below.
vagrant#vagrant-ubuntu-trusty-32:/usr/lib/haskell-packages$ cabal sandbox --help
cabal: unrecognised command: sandbox (try --help)
Adding more details:
vagrant#vagrant-ubuntu-trusty-32:/usr/lib/haskell-packages$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library
vagrant#vagrant-ubuntu-trusty-32:/usr/lib/haskell-packages$ which cabal
/home/vagrant/.cabal/bin/cabal
vagrant#vagrant-ubuntu-trusty-32:/usr/lib/haskell-packages$ cabal --help
This program is the command line interface to the Haskell Cabal infrastructure.
See http://www.haskell.org/cabal/ for more information.
Usage: cabal COMMAND [FLAGS]
or: cabal [GLOBAL FLAGS]
Global flags:
-h --help Show this help text
-V --version Print version information
--numeric-version Print just the version number
Commands:
install Installs a list of packages.
update Updates list of known packages
list List packages matching a search string.
info Display detailed information about a particular package.
fetch Downloads packages for later installation.
unpack Unpacks packages for user inspection.
check Check the package for common mistakes
sdist Generate a source distribution file (.tar.gz).
upload Uploads source packages to Hackage
report Upload build reports to a remote server.
init Interactively create a .cabal file.
configure Prepare to build the package.
build Make this package ready for installation.
copy Copy the files into the install locations.
haddock Generate Haddock HTML documentation.
clean Clean up after a build.
hscolour Generate HsColour colourised code, in HTML format.
register Register this package with the compiler.
test Run the test suite, if any (configure with UserHooks).
bench Run the benchmark, if any (configure with UserHooks).
upgrade (command disabled, use install instead)
help Help about commands
For more information about a command use:
cabal COMMAND --help
To install Cabal packages from hackage use:
cabal install foo [--dry-run]
Occasionally you need to update the list of available packages:
cabal update
You can edit the cabal configuration file to set defaults:
/home/vagrant/.cabal/config
vagrant#vagrant-ubuntu-trusty-32:/usr/lib/haskell-packages$ cabal COMMAND --help
cabal: unrecognised command: COMMAND (try --help)
vagrant#vagrant-ubuntu-trusty-32:/usr/lib/haskell-packages$ cabal sandbox --help
cabal: unrecognised command: sandbox (try --help)

The Cabal installed by apt is a little older and this is likely the one in your PATH. It gets installed to /usr/bin. You can check with:
which cabal
And to see the version:
cabal -v
You should put the one in ~/.cabal/bin in your PATH first with:
export PATH="$HOME/.cabal/bin:$PATH
(Probably best to put this in your ~/.bash_profile or similar)
On my system:
.whogan:~$ which cabal
/home/whogan/.cabal/bin/cabal
.whogan:~$ cabal -V
cabal-install version 1.22.6.0
using version 1.22.4.0 of the Cabal library
.whogan:~$ /usr/bin/cabal -V
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library
Edit: Tried with a new Vagrant box, ran apt-get install haskell-platform and install from git:
[vagrant#vagrantbox:~] $ git clone git://github.com/haskell/cabal.git cabal-wip
Cloning into 'cabal-wip'...
remote: Counting objects: 48926, done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 48926 (delta 16), reused 0 (delta 0), pack-reused 48876
Receiving objects: 100% (48926/48926), 26.39 MiB | 10.37 MiB/s, done.
Resolving deltas: 100% (29033/29033), done.
Checking connectivity... done.
[vagrant#vagrantbox:~] $ cd cabal-wip
[vagrant#vagrantbox:~/cabal-wip][master] $ cabal install Cabal/ cabal-install/
Config file path source is default config file.
Config file /home/vagrant/.cabal/config not found.
Writing default configuration to /home/vagrant/.cabal/config
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
Resolving dependencies...
Configuring Cabal-1.23.0.0...
Building Cabal-1.23.0.0...
Preprocessing library Cabal-1.23.0.0...
[ 1 of 85] Compiling Distribution.Lex ( Distribution/Lex.hs, dist/build/Distribution/Lex.o )
..
[85 of 85] Compiling Distribution.Simple ( Distribution/Simple.hs, dist/build/Distribution/Simple.o )
In-place registering Cabal-1.23.0.0...
Installing library in /home/vagrant/.cabal/lib/Cabal-1.23.0.0/ghc-7.6.3
Registering Cabal-1.23.0.0...
Installed Cabal-1.23.0.0
[1 of 1] Compiling Main ( cabal-install/Setup.hs, cabal-install/dist/setup/Main.o )
Linking cabal-install/dist/setup/setup ...
Configuring cabal-install-1.23.0.0...
Building cabal-install-1.23.0.0...
Preprocessing executable 'cabal' for cabal-install-1.23.0.0...
[ 1 of 81] Compiling Distribution.Client.Utils.LabeledGraph ( Distribution/Client/Utils/LabeledGraph.hs, dist/build/cabal/cabal-tmp/Distribution/Client/Utils/LabeledGraph.o )
...
[81 of 81] Compiling Main ( Main.hs, dist/build/cabal/cabal-tmp/Main.o )
Linking dist/build/cabal/cabal ...
Generating manual page dist/build/cabal/cabal.1 ...
Installing executable(s) in /home/vagrant/.cabal/bin
Installed cabal-install-1.23.0.0
It's installed 1.23.0.0 to ~/.cabal/bin, but after this the PATH is still pointing to the system one:
[vagrant#vagrantbox:~/cabal-wip][master] $ which cabal
/usr/bin/cabal
[vagrant#vagrantbox:~/cabal-wip][master] $ cabal -V
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library
So I modify to put the user/git version first:
[vagrant#vagrantbox:~/cabal-wip][master] $ export PATH="~/.cabal/bin:$PATH"
[vagrant#vagrantbox:~/cabal-wip][master] $ which cabal
/home/vagrant/.cabal/bin/cabal
[vagrant#vagrantbox:~/cabal-wip][master] $ cabal -V
cabal-install version 1.23.0.0
compiled using version 1.23.0.0 of the Cabal library
It seems OK after that:
[vagrant#vagrantbox:~/cabal-wip][master] $ mkdir ~/tmp && cd ~/tmp
[vagrant#vagrantbox:~/tmp] $ cabal sandbox init
Writing a default package environment file to
/home/vagrant/tmp/cabal.sandbox.config
Creating a new sandbox at /home/vagrant/tmp/.cabal-sandbox
I used trusty64 rather than trusty32 but I would hope that's not significant in this case.

Related

Can't install "System.Random" by cabal

I try to install "System.Random" by cabal through Powershell & Git Bash.
getting this result.
PS C:\Users\xxx> cabal install random
Resolving dependencies...
Up to date
Warning: You asked to install executables, but there are no executables in
target: random. Perhaps you want to use --lib to install libraries instead.
And then I try to input like this
cabal install --lib random
Resolving dependencies...
and
cabal install random --lib
both output Resolving dependencies... Up to date without warning.
but ghci Could not find module `System.Random'
input cabal install random still having the same result with warning.
It is a bad idea to install packages globally, so cabal install doesn't do that. The package is built and placed into the Cabal package database, but GHC won't find it unless you specifically tell Cabal to point GHC at it:
cabal repl -b random # -b is short for --build-depends
# Note that cabal install isn't really necessary: the above command would have installed random if it wasn't there already
I think your Cabal/GHC installation might be outdated, however. When you do cabal install --lib random, recent versions of Cabal should write out an "environment file" at %APPDATA%\ghc\arch-os-ghcversion\environments\default, which GHC should then automatically read (GHCi should say something like Loaded package environment from ...), and it should then find the installed package. If you are using the latest version of everything,
cabal install --lib random
ghci
should work.

Cabal claims it has updated itself but has not really

Following the instructions from this post on how to update cabal-install, I seemed to be able to install the latest version (or at least some version > 1.18, which is what I wanted.
$ cabal install Cabal cabal-install
Resolving dependencies...
Configuring cabal-install-1.22.6.0...
Building cabal-install-1.22.6.0...
Preprocessing executable 'cabal' for cabal-install-1.22.6.0...
<snip>
Linking dist/build/cabal/cabal ...
Installing executable(s) in /home/kavi/.cabal/bin
Installed cabal-install-1.22.6.0
However, when I tried cabal sandbox, it failed, so I checked cabal --version.
$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library
As you can see, the version is not the one that cabal claimed to install.
Adding ~/.cabal/bin to my path did nothing to help. (Yes, I did restart my terminal).
$ echo $PATH
<snip>:/home/kavi/.cabal/bin
$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library
I tried restarting my computer, but still:
$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library
I am using Ubuntu 14.04.
You should add /home/kavi/.cabal/bin to the beginning of the $PATH.
which cabal tells which executable shell will pick to execute, on my machine:
% echo $PATH
/Users/ogre/.local/bin:...
% which cabal
/Users/ogre/.local/bin/cabal

cabal sdist: tests inappropriate type

I just completed my first executable + library + tests in Haskell.
Unfortunately I can't create the tar-ball with the cabal sdist command.
cabal install --enable-tests && cabal build && cabal test are working without problems
cabal check returns only the warning for -O2
>> cabal sdist --verbose
creating dist/src
creating dist/src/sdist.-15440/UTFTConverter-0.1.0.0
Distribution quality warnings:
'ghc-options: -O2' is rarely needed. Check that it is giving a real benefit
and not just imposing longer compile times on your users.
Building source dist for UTFTConverter-0.1.0.0...
Preprocessing library UTFTConverter-0.1.0.0...
Preprocessing executable 'UTFTConverter' for UTFTConverter-0.1.0.0...
Preprocessing test suite 'library-tests:' for UTFTConverter-0.1.0.0...
creating dist/src/sdist.-15440/UTFTConverter-0.1.0.0/src
creating dist/src/sdist.-15440/UTFTConverter-0.1.0.0/src/Format
creating dist/src/sdist.-15440/UTFTConverter-0.1.0.0/tests
creating dist/src/sdist.-15440/UTFTConverter-0.1.0.0
Installing src/Format.hs to
dist/src/sdist.-15440/UTFTConverter-0.1.0.0/src/Format.hs
Installing src/Format/C.hs to
dist/src/sdist.-15440/UTFTConverter-0.1.0.0/src/Format/C.hs
Installing src/Format/Converter.hs to
dist/src/sdist.-15440/UTFTConverter-0.1.0.0/src/Format/Converter.hs
Installing src/Format/Raw.hs to
dist/src/sdist.-15440/UTFTConverter-0.1.0.0/src/Format/Raw.hs
Installing src/Format/RGB565.hs to
dist/src/sdist.-15440/UTFTConverter-0.1.0.0/src/Format/RGB565.hs
Installing src/Main.hs to
dist/src/sdist.-15440/UTFTConverter-0.1.0.0/src/Main.hs
Installing tests/Tests.hs to
dist/src/sdist.-15440/UTFTConverter-0.1.0.0/tests/Tests.hs
Installing LICENSE to dist/src/sdist.-15440/UTFTConverter-0.1.0.0/LICENSE
Installing Setup.lhs to dist/src/sdist.-15440/UTFTConverter-0.1.0.0/Setup.lhs
Installing ./UTFTConverter.cabal to
dist/src/sdist.-15440/UTFTConverter-0.1.0.0/./UTFTConverter.cabal
creating dist/src/sdist.-15440/UTFTConverter-0.1.0.0
Installing tests to dist/src/sdist.-15440/UTFTConverter-0.1.0.0/tests
cabal: tests: inappropriate type
My cabal version is
>> cabal -V
cabal-install version 1.18.1.0
using version 1.18.1.3 of the Cabal library
My GHC version is
>> ghc -V
The Glorious Glasgow Haskell Compilation System, version 7.8.3
Here is the github page to the project, maybe somebody can reproduce this error. >> Link <<
Remove tests from your extra-source-files section. You can't put directories in that section.

dependenacy libraries when installing svgcairo

I want to run a Setup.hs file to install svgcairo library, So I run first the command runhaskell Setup.hs configure --prefix=/usr/local but it's give me the following error :
Configuring svgcairo-0.13.0.1...
setup: At least the following dependencies are missing:
cairo >=0.13.0.0 && <0.14, glib >=0.13.0.0 && <0.14
This is confused me, since both cairo and glib are installed with the correct versions !
to make it convince, I have run the commands cabal install cairo and cabal install glib, and the following output appear:
Resolving dependencies...
All the requested packages are already installed:
cairo-0.13.0.6
Use --reinstall if you want to reinstall anyway.
Resolving dependencies...
All the requested packages are already installed:
glib-0.13.0.7
Use --reinstall if you want to reinstall anyway.
Note : I tried to run the Setup.hs file with runhaskell Setup.hs but its tell me that no command given (try --help)
cabal install defaults to installing to the local package database. Setup.hs defaults to installing to the global package database (hence will ignore anything installed in the local package database when trying to satisfy dependencies). You can change the behavior of either by passing --local or --global to the appropriate stage -- configure for Setup.hs, and configure or install for cabal.

Cabal install reports package as installed, but Setup configure reports it as missing

I am using ghc-7.6.3 with cabal-install version 1.18.0.5 using version 1.18.1.3 of the Cabal library. My operating system is Debian Wheezy 7.5.
I have a fresh cabal install, and that I have removed the .ghc from my home directory.
After that I have changed the cabal config file and set:
remote-repo: stackage-nightly-2014-12-15:http://www.stackage.org/snapshot/nightly-2014-12-15
After that I did (following this documentation)
$ cabal update
$ cabal install alex happy yesod-bin
and the build complained that it cannot build package system-filepath-0.4.12.
So, I am trying to build package system-filepath-0.4.12 manually. After unpacking the archive, I cd-ed to the unpacked folder and entered:
$ ghc -o Setup Setup.hs
$ ./Setup configure
which gives:
Configuring system-filepath-0.4.12...
Setup: At least the following dependencies are missing:
text >=0.7.1
But
$ cabal install text
gives:
Resolving dependencies...
All the requested packages are already installed:
text-1.1.1.3
Use --reinstall if you want to reinstall anyway.
How is it possible that a package is reported as installed and missing at the same time?
Should I look for a more stable remote-repo configuration, is there something I can check that might fix the missing text package? Note that I am not using a sandbox.
EDIT
Thanks for pointing out that there are two package databases.
I have now tried both
$ cabal configure
$ cabal build
and
$ Setup configure --user
$ Setup build
Both give no error during configuration, but give the following error during the build phase:
Building system-filepath-0.4.12...
Preprocessing library system-filepath-0.4.12...
/usr/bin/ld: cannot find -lHStext-1.1.1.3-ghc7.8.3
collect2: error: ld returned 1 exit status
Try this instead
cd system-filepath--0.4.12
cabal configure
I am not sure why, but this works for me, whereas Setup.hs gave me the same error (truth be told, I always do it the cabal configure way, and am not sure if your way should also work).
There are (at least) two package databases: a global one available to all users, and a user-specific one. By default, Setup.hs looks in (and installs to) the global one, and cabal-install looks in (and installs to) the user-specific one. You can manually choose one or the other with --user and --global; so, you could fix this either by using
./Setup configure --user
or by
cabal install text --global
You can see the current state of the package databases with ghc-pkg, which will report information about both by default.

Resources