`stack build --nix` results in /bin/bash: bad interpreter: No such file or directory - haskell

I've previous solved this issue, but I don't remember what I did... So thought I'd post it here to settle it.
I'm trying to build a Haskell package with stack build nix, I'm following the answer from https://stackoverflow.com/a/47110522/1663462 but it runs into an error of:
Unpacking GHC into /home/chris/.stack/programs/x86_64-linuRunning /home/chris/.stack/programs/x86_64-linux-nix/ghc-8.0.2.temp/ghc-8.0.2/configure --prefix=/home/chris/.stack/programs/x86_64-linux-nix/ghc-8.0.2/ in directory /home/chris/.stack/programs/x86_64-linux-nix/ghc-8.0.2.temp/ghc-8.0.2/ exited with ExitFailure 1
checking for path to top of build tree...
/home/chris/.stack/programs/x86_64-linux-nix/ghc-8.0.2.temp/ghc-8.0.2/configure: utils/ghc-pwd/dist-install/build/tmp/ghc-pwd-bindist: /bin/bash: bad interpreter: No such file or directory
configure: error: cannot determine current directory
How can I solve this?
stack --nix setup results in:
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Already downloaded.
Running /home/chris/.stack/programs/x86_64-linux-nix/ghc-8.0.2.temp/ghc-8.0.2/configure --prefix=/home/chris/.stack/programs/x86_64-linux-nix/ghc-8.0.2/ in directory /home/chris/.stack/programs/x86_64-linux-nix/ghc-8.0.2.temp/ghc-8.0.2/ exited with ExitFailure 1
checking for path to top of build tree...
/home/chris/.stack/programs/x86_64-linux-nix/ghc-8.0.2.temp/ghc-8.0.2/configure: utils/ghc-pwd/dist-install/build/tmp/ghc-pwd-bindist: /bin/bash: bad interpreter: No such file or directory
configure: error: cannot determine current directory
Error: Error encountered while configuring GHC with
/home/chris/.stack/programs/x86_64-linux-nix/ghc-8.0.2.temp/ghc-8.0.2/configure --prefix=/home/chris/.stack/programs/x86_64-linux-nix/ghc-8.0.2/
run in /home/chris/.stack/programs/x86_64-linux-nix/ghc-8.0.2.temp/ghc-8.0.2/
The following directories may now contain files, but won't be used by stack:
- /home/chris/.stack/programs/x86_64-linux-nix/ghc-8.0.2.temp/
- /home/chris/.stack/programs/x86_64-linux-nix/ghc-8.0.2/
Configuring GHC ...

nix:
enable: true
packages:
- pkgconfig
- autoconf
- gcc
- xorg.libX11
- xorg.libXext
- xorg.libXft
- xorg.libXinerama
- xorg.libXpm
- xorg.libXrandr
- xorg.libXrender
The above worked for me. I think it's just the autoconf that is needed. Answering with the full list in case it's not.

Related

cabal build error `gcc` failed: connot find `#include`

I try to build qhull from hackage and get the error
fatal error: qhull_ra.h: No such file or directory
2 | #include "qhull_ra.h"
`gcc' failed in phase `C Compiler'. (Exit code: 1)
The file is in the Cdir and the relevant parts of the cabal file are
include-dirs: ./Cdir
C-sources: ./Cdir/libqhull_r.c
, ./Cdir/geom_r.c
, ...
The file qhull_ra.h is not listed as C-sources, because it is a header file.
I did not write the code and are not experienced with including C code into haskell packages. The failure occurs sometimes and sometimes not, but I cannot tell when. What is wrong? I want to upload the package (authorized by the author); what do I have to change to make it compile with cabal install?
I've noticed that cabal install is (since recently) much more strict than cabal build when looking for files. So, I believe here the problem is that your include files are not being picked up by cabal.
I think you can fix that by listing your header files in a includes: field. So at least:
include-dirs: Cdir
includes: qhull_ra.h
c-sources: Cdir/libqhull_r.c
, ...

Haskell linker unable to open output file

I am new to Haskell and I am using cabal for a small project. The project is managed on github and it works fine if I run cabal run on the current code. There are also no errors if I enter ghci *.hs However, if I make any changes to the code at all, the following is printed to the terminal. What might be the issue here?
C:\Users\65963\scripting-hs> cabal run
Resolving dependencies...
Build profile: -w ghc-8.10.3 -O1
In order, the following will be built (use -v for more details):
- scripting-hs-0.1.0.0 (exe:scripting-hs) (configuration changed)
Configuring executable 'scripting-hs' for scripting-hs-0.1.0.0..
Preprocessing executable 'scripting-hs' for scripting-hs-0.1.0.0..
Building executable 'scripting-hs' for scripting-hs-0.1.0.0..
Linking C:\Users\65963\scripting-hs\dist-newstyle\build\x86_64-windows\ghc-8.10.3\scripting-hs-0.1.0.0\x\scripting-hs\build\scripting-hs\scripting-hs.exe ...
C://ProgramData//chocolatey//lib//ghc//tools//ghc-8.10.3//mingw//bin/ld.exe: cannot open output file C:\Users\65963\CS Projects\St Andrews CS\CS2006\CS2006-Haskell2\scripting-hs\dist-newstyle\build\x86_64-windows\ghc-8.10.3\scripting-hs-0.1.0.0\x\scripting-hs\build\scripting-hs\scripting-hs.exe: Invalid argument
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)

'cabal copy' failed during `stack build` in cifs directory

I'm following these instructions. I successfully did stack new and stack setup but stack build fails.
I found a git issue that this may be due to extra files listed in the cabal file, but removing them didn't fix the issue (and I'm just using the new-template without any changes). I am on Ubuntu 14.04 and installed stack using the script. Is there anything else I can look into?
It appears that this might be due to me trying to build inside of a cifs directory. Is there anything I can do to handle this?
# stack build
ehri-haskell-0.1.0.0: configure (lib + exe)
Configuring ehri-haskell-0.1.0.0...
ehri-haskell-0.1.0.0: build (lib + exe)
Preprocessing library ehri-haskell-0.1.0.0...
Preprocessing executable 'ehri-haskell-exe' for ehri-haskell-0.1.0.0...
ehri-haskell-0.1.0.0: copy/register
Installing library in
/mnt/docs/RubymineProjects/ehri-haskell/.stack-work/install/x86_64-linux/lts-8.6/8.0.2/lib/x86_64-linux-ghc-8.0.2/ehri-haskell-0.1.0.0-Kh3VLZPfbij7EgcL22QBMN
Installing executable(s) in
/mnt/docs/RubymineProjects/ehri-haskell/.stack-work/install/x86_64-linux/lts-8.6/8.0.2/bin
/mnt/docs/RubymineProjects/ehri-haskell/.stack-work/install/x86_64-linux/lts-8.6/8.0.2/bin/.copyFile5965166491189641421.tmp:
copyFile: does not exist (Host is down)
'cabal copy' failed. Error message:
-- While building package ehri-haskell-0.1.0.0 using:
/root/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.2.0 copy
Process exited with code: ExitFailure 1
One possible cause of this issue is:
* No module named "Main". The 'main-is' source file should usually have a header indicating that it's a 'Main' module.
# stack --version
Version 1.4.0, Git revision e714f1dd3fade19496d91bd6a017e435a96a6bcd (4640 commits) x86_64 hpack-0.17.0
Looks like the issue is caused by the depth of the folder where the project lives (Windows 10, x64). From the moment the depth exceeds some threshold, described error appears. So try moving the project folder up in directories tree.

Changing python headers directory for configure

I'm trying to build gnome-weather using jhbuild, but running build process results in the following errors:
checking for python extension module directory... ${exec_prefix}/lib64/python2.7/site-packages
checking for headers required to compile python extensions... ./configure: line 14697: /usr/local/bin/python-config: No such file or directory
not found
configure: error: Python headers not found
*** Error during phase configure of gobject-introspection: ########## Error running ./autogen.sh --prefix /home/pgolinski/jhbuild/install --disable-static --disable-gtk-doc *** [7/36]
[1] Rerun phase configure
[2] Ignore error and continue to build
[3] Give up on module
[4] Start shell
[5] Reload configuration
[6] Go to phase "wipe directory and start over"
[7] Go to phase "clean"
[8] Go to phase "distclean"
Strangely the error says that Python headers were not found even though I have python-devel installed. I managed to find python-config in usr/bin so how to change its directory for configure? Or maybe the problem lies elsewhere? (I just want to build gnome-weather)
you can download the last version of gnome-weather here:
https://git.gnome.org/browse/gnome-weather/snapshot/gnome-weather-3.14.1.zip
and compile that with these command after unzip it:
libtoolize
aclocal
autoheader
autoconf
automake --add-missing --foreign
./configure
make && make install
this should work.8y3
Here's what finally worked for me if someone struggles with something similair in future:
PYTHON=/usr/bin/python jhbuild build gnome-weather

Cannot install accelerate-cuda in Haskell

I am on a linux box and trying to experiment with Haskell's Accelerate library but having problems installing it. I have successfully installed the accelerate package but there seems to be a dependency problem, which I have detailed below.
cabal: Error: some packages failed to install:
accelerate-cuda-0.14.0.0 depends on haskell-src-exts-1.14.0.1 which failed to
install.
cuda-0.5.1.1 failed during the configure step. The exception was:
ExitFailure 1
haskell-src-exts-1.14.0.1 failed during the configure step. The exception was:
ExitFailure 1
haskell-src-meta-0.6.0.5 depends on haskell-src-exts-1.14.0.1 which failed to
install.
language-c-quote-0.7.6 depends on haskell-src-exts-1.14.0.1 which failed to
install.
I searched SO and noticed someone else had a similiar issue installed the cuda package, and was resolved by adding the cabal bin path to the PATH; I tried this but it didn't solve this problem.
Please could someone help as I really keen to play with this fantastic library.
I wanted to check accelerate-examples and play with them and I also didn't have CUDA GPU (AMD only) and that's how I eventually installed accelerate-examples with stack:
git clone https://github.com/AccelerateHS/accelerate-examples
cd accelerate-examples
#choose version:
ln stack-8.6.yaml stack.yaml
#build without CUDA targeting:
stack build --flag accelerate-examples:-llvm-ptx --flag accelerate-fft:-llvm-ptx
Installation will build all the examples and print the info regarding where they was put.
Might also need to specify GHC libs path with something like: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.stack/programs/x86_64-linux/ghc-8.6.5/lib/ghc-8.6.5/rts/
Also checked that accelerate installs as well the same way but even without specifying any flags (I guess because it doesn't build any programs yet?), but examples are what's fun :)
P.S. You can move llvm-ptx flags to stack.yaml config: change # flags: {} line to:
flags:
accelerate-fft:
llvm-ptx: false
accelerate-examples:
llvm-ptx: false

Resources