0
votes

I have a package named commands. I want to install it into its own sandbox e.g. .cabal-sandbox/x86_64-osx-ghc-7.8.3-packages.conf.d/commands-0.0.0-f3f84f48f42ac74a69ee5fd73512bfd0.conf. currently, there is just one .hi interface file for one module Commands, I don't know how it got there.

I tried cabal install commands, by the logic of "that's how the other packages got there I think", but it fails with unknown package.

I also tried stuff with ghc-pkg like ghc-pkg update commands -f .cabal-sandbox/x86_64-osx-ghc-7.8.3-packages.conf.d but I'm not using them right. ideally, I'd like to do this with cabal.

the last thing I tried was ghc -idist/build/, but it complained about the package names in the interface files being different, command versus main ("... differs from name found in the interface file ..."). and if I faked the executable's package with ghc -package-name commands-0.0.0, the linker complained that it couldn't find the symbol _ZCMain_main_closure, because every executable needs the function main in the module Main in the package main.

I'm sure there's a better way of doing this.

I followed online examples for my cabal file:

$ cat commands.cabal
name: commands
library
exposed-modules: Commands.Types, Commands.Bits
...

the minimal failing code example is just:

$ cat Main.hs
import Commands.Types
main = return ()

in the root project directory.

Context: I need to build my executable with make (not cabal) because it links to foreign code (Objective-C via language-c-inline). my makefile: https://github.com/sboosali/Haskell-DragonNaturallySpeaking/blob/master/Makefile). thus, I have to compile a script explicitly. I don't know how to compile the executable with cabal, but I want cabal to build and test and manage my library.

By putting my package into the sandbox, I will be able to import its modules from the script, by compiling with cabal exec -- ghc. I will also be able to include the script with extra-source-files at least, and know it will work.

2

2 Answers

2
votes

Here's what I'd try:

  1. First unregister any previous commands library. Try ghc-pkg --global unregister commands
  2. Install new commands to your sandbox. From your sandbox directory, try this: cabal --enable-shared --disable-documentation --prefix=./ install /path/to/your/library/source

Note the prefix specification.

0
votes

I nuked it (rm -fr .cabal-sandbox/), reinstalled everything (cabal install --only-dependencies), added itself as a source (cabal sandbox add-source .), installed it (cabal install command). and then make worked. idk...