Cabal: Does not exists in Windows 8.1 - haskell

Today I installed windows 8.1 and haskell on my laptop. I'm trying to build my own haskell library, but I got an error when I try to use cabal sdist. This is the error:
D:\Development\School\AFP\Assignments\Practice\Exercise\Project>cabal sdist
Distribution quality errors:
'license: NONE' is not a recognised license. The known licenses are: GPL,
GPL-2, GPL-3, LGPL, LGPL-2.1, LGPL-3, AGPL, AGPL-3, BSD2, BSD3, MIT, ISC,
MPL-2.0, Apache, Apache-2.0, PublicDomain, AllRightsReserved, OtherLicense
Distribution quality warnings:
No 'category' field.
No 'maintainer' field.
No 'synopsis' field.
A 'license-file' is not specified.
When distributing packages it is encouraged to specify source control
information in the .cabal file using one or more 'source-repository' sections.
See the Cabal user guide for details.
Note: the public hackage server would reject this package.
Warning: Cannot run preprocessors. Run 'configure' command first.
Building source dist for Project-0.1.0.0...
cabal: does not exist
Before I used the "cabal sdist" I used the following commands:
cabal init
cabal sandbox init
cabal install -j
Every command succeed, except for the cabal sdist. The cabal install only gives the following warning:
D:\Development\School\AFP\Assignments\Practice\Exercise\Project>cabal install -j
Resolving dependencies...
In order, the following will be installed:
Project-0.1.0.0 (reinstall)
Warning: Note that reinstalls are always dangerous. Continuing anyway...
Notice: installing into a sandbox located at
D:\Development\School\AFP\Assignments\Practice\Exercise\Project\.cabal-sandbox
Configuring Project-0.1.0.0...
Building Project-0.1.0.0...
Installed Project-0.1.0.0
This is my Project.cabal file:
-- Initial Project.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
-- Initial Project.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: Project
version: 0.1.0.0
-- synopsis:
description: Education
license: NONE
-- license-file:
-- author:
-- maintainer:
-- copyright:
-- category:
build-type: Simple
extra-source-files: File6, File5, File4, File3, File2
cabal-version: >=1.10
library
exposed-modules: File1
-- other-modules:
-- other-extensions:
build-depends: base >=4.8 && <4.9, QuickCheck >=2.8 && <2.9
hs-source-dirs: src
default-language: Haskell2010
I tried google, but I can't find a good solution. I use the following versions:
Cabal version: 1.22.4.0
Haskell version: 7.10.2
If you need more information, please ask.

I don't know anything about sdist, but the problem is clear: you've specified 'NONE' as the license in your cabal file, but that is not allowed for the sdist option. configure, build, and init don't care about the specific license, but sdist apparently does.
For more info, I searched google for "cabal sdist" and found this.
This [cabal sdist] has the advantage that Cabal will do a bit more checking, and ensure that the tarball has the structure that HackageDB expects.
HackageDB probably expects a valid license, hence why "NONE" is not allowed.

The problem was that cabal could not find the files in extra-source-files. I thought I didn't had to add the extension of the haskell files, but this is required.
I also had another problem. The extra-source-files wasn't using the hs-source-dirs, so I had to explicitly write "src/" infront of a file.

Related

Haskell Cabal: omitting version a big mistake

I ran cabal build on a *.cabal file that doesn't have a version: specified and it seems to have confused cabal. When I put back the version specification, I got
$ cabal build
Resolving dependencies...
TODO: add support for multiple packages in a directory. Got
yah-0.1.0.0
yah-0.1.0.0
CallStack (from HasCallStack):
error, called at src\\Distribution\\Client\\ProjectOrchestration.hs:586:9 in cabal-install-3.8.1.0-inplace:Distribution.
Client.ProjectOrchestration
That is, normally the yah.cabal file would read
cabal-version: 3.0
name: yah
version: 0.1.0.0
license: etc., etc.
and cabal build was fed the above without the version and maybe without the cabal-version -- not sure. In any case, starting over with cabal init doesn't fix it, but other projects can be compiled fine.
My guess is that the various modules that are in the yah project are registered somewhere/somehow and it's not clear how to expunge that and start over. I'm on Windows, cabal 3.8.1.0. I've looked in C:\cabal, C:\ghccup, C:\Users\...\AppData\Roaming\cabal...
It looks like you have more than one .cabal file in that directory. Remove the one that's not named yah.cabal.

Cannot build project with z3-haskell on windows 10

I want to build the haskell bindings for z3 in a Cabal project, the following is the minimum (faulty) example:
Using a project initialized by cabal init:
test/
- Main.hs
- Setup.hs
- CHANGELOG.md
- test.cabal
With modified test.cabal:
cabal-version: 3.0
name: z3-test
version: 0.1.0.0
extra-source-files: CHANGELOG.md
executable test
main-is: Main.hs
build-depends: base >=4.14 && <4.15
, z3 ^>=408.2
default-language: Haskell2010
Z3 binaries are located at C:\z3-4.8.5-x86-win.
Z3-bindings are installed:
cabal v1-install z3 --extra-lib-dirs=C:/z3-4.8.5-x64-win/bin --extra-include-dirs=C:/z3-4.8.5-x64-win/include -v3
All the requested packages are already installed:
z3-408.2
Use --reinstall if you want to reinstall anyway.
Now building the project using:
cabal v2-build --extra-lib-dirs=C:/z3-4.8.5-x64-win/bin --extra-include-dirs=C:/z3-4.8.5-x64-win/include -v3
Results in the error:
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
- z3-408.2 (lib) (requires build)
- z3-test-0.1.0.0 (exe:test) (first run)
Starting z3-408.2 (lib)
Failed to build z3-408.2. The failure occurred during the configure step.
Build log (
C:\cabal\logs\ghc-8.10.2\z3-408.2-1722a25655334afbca91ac935f14ff0d20ccf8c4.log
):
Configuring library for z3-408.2..
cabal.exe: Missing dependency on a foreign library:
* Missing (or bad) header file: z3.h
* Missing (or bad) C library: z3
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
library file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
cabal.exe: Failed to build z3-408.2 (which is required by exe:test from
z3-test-0.1.0.0). See the build log above for details.
How can I build a project with the z3 bindings?
Note that:
GHC version = 8.10.2
Cabal version = 3.2.0.0
I can only use cabal
Using cabal install ... or cabal v2-install ... results in Cannot build .. z3 because none of the components are available to build:

Dependency issues running "cabal test" for Haskell

I'm running my first "cabal test" for Haskell, but I get the error:
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
Configuring sample-0.1.0.0...
cabal: At least the following dependencies are missing:
base ==4.7.*
sampel.cabal:
-- Initial sample.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: sample
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.10
executable SampleTest
main-is: SampleTest.hs
build-depends: base >= 4.7 && <4.8, HUnit >=1.2 && <1.3
hs-source-dirs: test, src
default-language: Haskell2010
Any help appreciated.
Versions of GHC come bundled with versions of base. GHC 7.10.2 uses base 4.8.1.0.
Your cabal must be using a slightly out of date template....
You should either change the range of acceptable base version (as you did in your comment above), or use a different version of GHC.

haskell-mode with sandboxes

I have tried the following:
cabal sandbox init
Then making the following cabal file.
-- Initial hsource.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: hsource
version: 0.1.0.0
-- synopsis:
-- description:
-- license:
license-file: LICENSE
author: abc
maintainer: abc
-- copyright:
-- category:
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
executable hsource
main-is: main.hs
other-modules:
-- other-extensions:
build-depends: base >=4.7 && <4.8, csv
hs-source-dirs: src
default-language: Haskell2010
Now I install the CSV package with:
cabal install --only-dependencies
Now when I try import Text.CSV then then C-c C-l I get the following error:
Util/RandomTree.hs:7:8-15: Could not find module ‘Text.CSV’ …
Use -v to see a list of the files searched for.
Compilation failed.
So my question is if sandboxes are not supported in haskell-mode or am I missing some steps to get them to work?
Make sure you have:
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
in your emacs init file.
There are different GHCi process types supported by haskell-mode. You need one that uses cabal.
To find out what process type is currently applied, use M-x describe-variable and enter haskell-process-type.
I think the haskell-mode documentation is out of date; because, looking at the source code, the default is auto, which will use cabal-repl if it is able to locate a .cabal-sandbox directory. Otherwise, it will use ghci.
So, if your haskell-process-type is set to ghci or auto and it's unable to locate your cabal sandbox, you will see the error you posted. If it's currently set to ghci, change the haskell-process-type to cabal-repl by adding:
(custom-set-variables
'(haskell-process-type 'cabal-repl))
to your emacs init file and restarting the emacs process.
Also, you can always confirm that the problem is specific to emacs by opening a command line, navigating to the directory containing your .cabal file and entering cabal repl. If that works, then your cabal setup is fine.

Automatically List Dependencies For a Project

Given a Haskell project, is there a way to automatically calculate the entire list of dependencies? All the libraries it depends on as well as libraries that have been included but are not required.
As I said in the comments, cabal-install already does this (I'm using cabal-install 0.14.0) by guessing the packages via module lookup (like GHCi). It doesn't have any real intelligence w.r.t. versions so it just sets the version to the match major version of what you have installed.
Below you can see me making a dummy package that imports Data.Vector and cabal-install infers I am using vector 0.9.*.
[tommd#mavlo blah]$ pwd
/tmp/blah
[tommd#mavlo blah]$ cat Data/Blah.hs
module Data.Blah where
import Data.Vector
[tommd#mavlo blah]$ cabal init
Package name? [default: blah]
...SNIP...
What does the package build:
1) Library
2) Executable
Your choice? 1
Include documentation on what each field means (y/n)? [default: n]
Guessing dependencies... <--- SEE, SEE! YAY!
Generating LICENSE...
Warning: unknown license type, you must put a copy in LICENSE yourself.
Generating Setup.hs...
Generating blah.cabal...
You may want to edit the .cabal file and add a Description field.
[tommd#mavlo blah]$ cat blah.cabal
-- Initial blah.cabal generated by cabal init. For further documentation,
-- see http://haskell.org/cabal/users-guide/
name: blah
version: 0.1.0.0
synopsis: Sisponys
-- description:
-- license:
license-file: LICENSE
author: Me
maintainer: No#No.No
-- copyright:
-- category:
build-type: Simple
cabal-version: >=1.8
library
exposed-modules: Data.Blah
-- other-modules:
build-depends: base ==4.5.*, vector ==0.9.* <-- SEE?? SEE! YIPPEE!!

Resources