Haskell stack build error "No local directories found as children" - haskell

When running stack build --no-terminal --install-ghc, I run into Error parsing targets: No local directories found as children.
I can understand what it means, but why does it happen? I haven't read anywhere in the Stack manual about having to create extra directories ..
Thanks in advance

What's your stack version? Can you still reproduce this with the latest?
This means that it is parsing an argument as if it is a TARGET, but isn't finding the dir. I think in old versions of stack, unrecognized flags would get parsed this way. So, if you're using a command intended for newer stack, this error can happen.

Related

Haskell stack gives InvalidRelDir error no matter the input

I am encountering the following error every time I try to use stack except for stack --version:
PS D:\Currentdir\version2\code> stack update
InvalidRelDir "D:\\Currentdir\\code\\.stack-work"
PS D:\Currentdir\version2\code> stack clean
InvalidRelDir "D:\\Currentdir\\version2\\code\\.stack-work"
PS D:\Currentdir\version2\code> stack test
InvalidRelDir "D:\\Currentdir\\version2\\code\\.stack-work"
PS D:\Currentdir\version2\code>
I think I deleted the .stack/work subfolder in one of my projects (from within Windows 10 file explorer), and this might be causing the problems since the commands might look for that specific folder, and since stack test did work before.
There are however .stack-work subfolders in other projects such as in the one indicated above. So I am not entirely sure.
I just discovered that my stack has somehow been set to look for a .stack-work folder that is within a specific folder, as seen below where I have tried to navigate first to other folders and after that to that particular folder in windows powershell:
PS D:\Redo_haskell_folder\code> stack path
InvalidRelDir "D:\\HaskellAppFolder\\version2\\code\\.stack-work"
PS D:\Redo_haskell_folder\code> stack --stack-root STACK-ROOT
option --stack-root: InvalidAbsDir "STACK-ROOT"
PS C:\sr> stack path
InvalidRelDir "D:\\HaskellAppFolder\\version2\\code\\.stack-work"
PS D:\HaskellAppFolder\version2\code> stack path
InvalidRelDir "D:\\HaskellAppFolder\\version2\\code\\.stack-work"
I have tried the following steps to troubleshoot the "InvalidRelDir" error when running stack update or stack clean, I:
Made sure that I am using the latest version of stack by running stack --version and tried updating stack with stack upgrade.
Checked the contents of my stack.yaml file to make sure that it is correct and specifies the correct dependencies and packages for my project. It is just the one initilialized with the stack init in my current folder.
Ran stack init in my project directory to create a new stack.yaml file and configure my project for use with stack. This gives back the same error message.
Tried to delete the .stack-work directory using Remove-Item -Recurse -Force .stack-work (I am using windows 10 and powershell terminal) and ran stack update or stack clean again to see if the issue is resolved. The remove-command caused same InvalidRelDir error.
Tried to change the permission of the folders I am working in, within the windows 10 explorer, by un-checking the 'Read only'-permission. The problem persists.
I also tried suing stack-root I get the following in the powershell prompt
code> stack --stack-root STACK-ROOT
option --stack-root: InvalidAbsDir "STACK-ROOT"
Despite these efforts, I am still encountering the "InvalidRelDir" error. I haven't been able to find any posts that mentions the same problem they encountered, any good ideas?
EDIT
Since I have gotten very few responses, perhaps I could help open op the trouble shooting by asking about the default location for stack root.
Furthermore is there a way to un-install only stack rather than all of the ghc and cabal packages that comes with it?
EDIT EDIT
Or if none of the above works, would there be a way to uninstall the above and re-install in such a way that I would have taken into consideration the multiple .stack-work folders that might have been created from my trouple shooting proces.
EDIT x3
I finally found the InvalidRelDir in the documentation - not for stack as such but at hackage . As far as I can see this is a haskell documentation, and somehow the stack build is using the function parselRelDir described as:
parseRelDir :: MonadThrow m => FilePath -> m (Path Rel Dir)
Convert a relative FilePath to a normalized relative dir Path.
Throws: InvalidRelDir when the supplied path:
is not a relative path
is ""
contains a .. path component representing the parent directory
is not a valid path (See isValid)
I suspect that I get the error because the stack library is using this library as well. If any of you find this to be an incorrect tenet or have any suggestions about how to proceed from here without uninstalling all of stack it will be appreciated.
As seen in the post above, I have now narrowed the problem down even further, to some kind of 'pointer' to an 'old' or wrong directory. And I think my question therefore is: "Is there a way to 'reset' the .stack-workfolder that stack is looking for with the parseRelDir function mentioned before?"
I have now uninstalled stack according to: this and have in that process also removed C:\sr and the %AppData%\Roaming\stack.
I have then installed it with this windows package as recommended from official documentary.
I do however still get the same error now that I have installed it again.
EDIT x4
I have now made progress! I went to "Edit System Variables" and edited "STACK ROOT" to C:\sr and C:\sr\.stack-work but got the following error with the output of those paths respectively
PS D:\Redo_haskell_folder\code> stack path InvalidRelDir "C:\\sr"
So now that I know why the pointer kept being the same despite re-installing stack, I now have to find out the following: What is the correct path for "STACK ROOT"
PS: after reinstalling the C:\sr is empty except for a config.yaml file
I got in touch with the stack-support and used the following 'reset of the STACK_ROOT' to solve the issue.
STACK_ROOT is an environment variable that specifies the location of
the Stack Root directory. See
https://docs.haskellstack.org/en/stable/environment_variables/#stack_root.
See also:
https://docs.haskellstack.org/en/stable/global_flags/#the-stack-root-option.
On Windows, the default value is C:\sr (because some Windows operating
systems have problems with long paths). Stack will populate the Stack
root the first time it needs the contents of the Stack root.
❯ echo $Env:STACK_WORK
> $Env:STACK_WORK="C:\temp"
> echo $Env:STACK_WORK
C:\temp
> stack path --dist-dir
InvalidRelDir "C:\\temp"
> $Env:STACK_WORK=""
> stack path --dist-dir
.stack-work\dist\8a54c84f

Starting with Platform.sh - trying to get project, receiving error "The provided cwd does not exist." what does this mean?

Starting with Platform.sh - trying to get project, receiving error "The provided cwd does not exist." what does this mean?
The error literally reads "[RuntimeException] The provided cwd does not exist."
No clue what that means. I run the following command in git bash:
platform get [id]
Which should get my project. But I get that error. :/
I work at Platform.sh.
This was a bug in the Platform.sh CLI that affected use on Windows. It has been fixed in later versions, from v3.25.1 (the root cause was a bug in Symfony Console). Sorry for the inconvenience.
Please use the Platform.sh docs and support to get help faster.
I suppose you are referring to Platform.sh, the Continuous Deployment Cloud Hosting.
As mentioned in "platformsh-cli PR 155":
It is possible to run the command from inside the repository directory, but it leaves the shell in a weird state, at least when using ZSH (it reports the wrong cwd).
So make sure you did a project:init before the get.

Haskell Stack `exec` executable not found despite path being searched

Creating a fresh haskell-stack project fails to find the project-exec executable, despite searching the appropriate path. I'm not sure why. In particular,
stack build creates the project-exec inside $PROJECT_DIR/.stack-work/install/x86_64-linux-ncurses6/.../bin/project-exe
However, stack exec project-exec fails with:
Executable named rse8-exec not found on path: ["$PROJECT_DIR/.stack-work/install/x86_64-linux-ncurses6/lts-7.14/8.0.1/bin", ]
(to clarify, $PROJECT_DIR references and ... are (hopefully) obvious placeholders for paths. the actual error contains the full path)
Apologies for the lack of attention showed here. This question should probably just be deleted.
Stack creates a file named <project>-exe not <project>-exec.
Stack replaces dashes - with underscores _. Try stack exec project_exec see if it works.
This should have been a comment actually, but I don't have enough reputation to write a comment, while I have enough to post an answer!

Stack InvalidRelFile error when adding local package

I'm having this strange issue : I'm trying to add a local package to my stack file and I get the following error. when I try to build it (stack build) it kind of work but fails suggesting me to use stack solver but when I run stack solver I got the following error
Using configuration file: stack.yaml
InvalidRelFile "/home/max/devel/sql-fragment/sql-fragment.cabal"
My stack file looks like
flags: {}
packages:
- '.'
- ../sql-fragment
extra-deps:
...
I'm on Ubuntu 15.02 trying to use GHC-7.8.4 and stack 1.0.4
The two packages, sql-fragment and sql-fragment-mysql-simple can be found on github.
It's probably a bug in stack. I managed to find a workaround by moving sql-fragment directory into sql-fragment-mysql-simple, change ../sql-fragment to sql-fragment in the stack file launch the solver -stack solver --update-config and it works. What is strange is, I add to properly move the directory to make it work (just creating a symbolic link woudn't work) and once the solver has done its job. I moved sql-fragment where it was, revert the path to ../sql-fragment and stack build works perfectly ;-).
Fixed with this commit. https://github.com/commercialhaskell/stack/commit/42a61fb278aeb99ad61bb088da9a87b2313ac325
The issue tracker is a better place for this.

How do get stack to collect the sources?

Let's say I want to gather all the dependencies for a package using stack on machine A and then compile it with ghc on machine B. How do I do that?
The reason I want to this is I'm having trouble installing stack on this one computer, so it would be easier if I could get stack to put into one big Haskell file or something, and then compile it on the other computer.
This is a bit of a strange thing to want to do, sorry you are having trouble installing it.
You can use this in bash to unpack all transitive dependencies:
stack list-dependencies --separator "-" | while read pkg; do stack unpack $pkg; done
(from https://github.com/commercialhaskell/stack/issues/1843)
You'll also need to be sure to use the correct GHC version, cabal version etc.

Resources