stack 2.7.1: build fails with resource busy (Text file busy) on Ubuntu - haskell

I'm unable to do stack build for any projects on Ubuntu 20.04 or 18.04 running as a VirtualBox guest on Windows 10. Building fails when trying to rename a temp file: .stack-cabal-mod11115-0.tmp: rename: resource busy (Text file busy)
edit: this appears to only happen on VirtualBox shared folders. Stack can successfully build a project in a folder that is not shared with the Windows hot.
I've previously had no issues with 1.9.x versions of stack in identical environments. At this point I'm not even able to get stack build to compile a new project on a clean Ubuntu installation. If I downgrade to 1.9.3 everything magically works. I've deleted ~.stack and .stack-work folders and retried without success.
Below is the output on a new project using stack new. I'm able to use stack repl, although I still get an error message about the build failing with
vagrant#ubuntu-focal:/vagrant/test$ stack --version
Version 2.7.1, Git revision 8afe0c2932716b0441cf4440d6942c59568b6b19 x86_64 hpack-0.34.4
vagrant#ubuntu-focal:/vagrant/test$ stack setup
Preparing to install GHC (tinfo6) to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-tinfo6-8.10.4.
Installed GHC.
stack will use a sandboxed GHC it installed
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec
vagrant#ubuntu-focal:/vagrant/test$ stack build
[1 of 2] Compiling Main ( /home/vagrant/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /home/vagrant/.stack/setup-exe-src/setup-mPHDZzAJ.o )
[2 of 2] Compiling StackSetupShim ( /home/vagrant/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /home/vagrant/.stack/setup-exe-src/setup-shim-mPHDZzAJ.o )
Linking /home/vagrant/.stack/setup-exe-cache/x86_64-linux-tinfo6/tmp-Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.4 ...
Building all executables for `test' once. After a successful build of all of them, only specified executables will be rebuilt.
test> configure (lib + exe)
Configuring test-0.1.0.0...
/vagrant/test/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/.stack-cabal-mod11009-2.tmp: rename: resource busy (Text file busy)
vagrant#ubuntu-focal:/vagrant/test$ stack build
Building all executables for `test' once. After a successful build of all of them, only specified executables will be rebuilt.
test> configure (lib + exe)
Configuring test-0.1.0.0...
/vagrant/test/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/.stack-cabal-mod11115-0.tmp: rename: resource busy (Text file busy)
Thanks.

Related

Haskell Stack - how to disable copying executables during stack test?

After invoking
stack new foo
stack build foo:test:foo-test --test --fast --no-copy-bins --no-copy-compiler-tool
Stack is still copying and installing library and executables:
foo> copy/register Installing library in
/tmp/foo/.stack-work/install/x86_64-linux-tinfo6/c2ce3190a19b85be796c6c0a3948129db378f9cd184b6b091f74bef68e262808/8.8.4/lib/x86_64-linux-ghc-8.8.4/foo-0.1.0.0-JFvztN1xJpOHaq2zHLpyHS
Installing executable foo-exe in
/tmp/foo/.stack-work/install/x86_64-linux-tinfo6/c2ce3190a19b85be796c6c0a3948129db378f9cd184b6b091f74bef68e262808/8.8.4/bin
Registering library for foo-0.1.0.0..
How can I disable copying of executables during stack build --test? I have a project with dozen of executables and copying of them takes longer than executing tests...
% stack --version
Version 2.5.1, Git revision d6ab861544918185236cf826cb2028abb266d6d5 x86_64 hpack-0.33.0

stack rebuild all all packages

Question
Is there a way to force stack to rebuild all local precompiled packages?
Context
I had a working stack installation but I've updated my ArchLinux (including kernel update) and I get this now:
stack ghci
Main.hs: <command line>: can't load .so/.DLL for: /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/../../../../lib/libncurses.so (-lncursesw: cannot open shared object file: No such file or directory)
Since the given exists my guess is that the compiled version isn't linked correctly, that's why I try to rebuild everything.

'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.

stack cannot build network - where's config.log?

I have a project to build with stack and it depends on network. When I do stack build, it says
[1 of 1] Compiling Main ( /tmp/stack23678/network-2.6.2.1/Setup.hs, /tmp/stack23678/network-2.6.2.1/.stack-work/dist/i386-linux/Cabal-1.22.5.0/setup/Main.o )
Linking /tmp/stack23678/network-2.6.2.1/.stack-work/dist/i386-linux/Cabal-1.22.5.0/setup/setup ...
Configuring network-2.6.2.1...
...
checking whether the C compiler works... no
configure: error: in `/tmp/stack23678/network-2.6.2.1':
configure: error: C compiler cannot create executables
See `config.log' for more details
Sure, I'd love to. But where is this config.log? Or how can I re-create it?
Just cabal install network (without stack) works fine but how could stack build use this?
In order to get better information here, you can make sure all generated files are saved by manually building network:
stack unpack network-2.6.2.1
cd network-2.6.2.1
stack init
stack build
I think C compiler cannot create executables means you don't have a working C compiler installed.
config.log is generated by the configure command, and I don't think stack saves that. stack does save other logging output in
~/.stack/global-project/.stack-work/logs/...
It's the same as what was emitted to your terminal, so it may not help.

GHC could not execute gcc.exe in Yesod Installation

I followed "Yesod quick start guide" to install Yesod in Windows 10.
But, when I issued the stack build command, it failed.
Environment
Windows 10 (64bits)
stack-0.1.5 (for Windows10 64bits)
No Haskell Platform
I executed these commands
stack new my-project yesod-sqlite && cd my-project
stack install yesod-bin cabal-install --install-ghc
stack setup
stack build <--- the error occured
In 'stack build' command, the package installations were done. But, when it build the project, the error occured.
Command Prompt
>stack build
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
my-project-0.0.0: build
Preprocessing library my-project-0.0.0...
In-place registering my-project-0.0.0...
Preprocessing executable 'my-project' for my-project-0.0.0...
Linking .stack-work\dist\x86_64-windows\Cabal-1.22.4.0\build\my-project\my-project.exe ...
ghc.exe: could not execute: C:\Users\xxxxx\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.2\lib/../mingw/bin/gcc.exe
-- While building package my-project-0.0.0 using:
C:\Users\xxxxx\AppData\Roaming\local\bin\stack-0.1.5.0\setup-exe-cache\setup-Simple-Cabal-1.22.4.0-x86_64-windows-ghc-7.10.2.exe --builddir=.stack-work\dist\x86_64-windows\Cabal-1.22.4.0\ build lib:my-project exe:my-project --ghc-options -ddump-hi -ddump-to-file
Process exited with code: ExitFailure 1
This is caused by the argument length limit on Windows. Starting in GHC 7.10.3, GHC will support response files for sending linker arguments in order to bypass this limitation. In the meanwhile, a workaround is to manually make the path to your stack root shorter by setting the STACK_ROOT environment variable.
For more information, see https://www.fpcomplete.com/blog/2015/08/stack-ghc-windows

Resources