Haskell stack gives InvalidRelDir error no matter the input - haskell

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

Related

weird error with haskell-stack. it doesn't install anything anymore

I get an error with stack, while trying to install a package.
Run from outside a project, using implicit global project config
Using resolver: lts-8.0 from implicit global project's config file: /home/chuck/.stack/global-project/stack.yaml
Invalid package ID: "array-0.5.1.1 base-4.9.1.0 binary-0.8.3.0 bytestring-0.10.8.1"
stack --version works:
Version 0.1.10.0 x86_64
and stack setup returns this:
Run from outside a project, using implicit global project config
Using resolver: lts-8.0 from implicit global project's config file: /home/chuck/.stack/global-project/stack.yaml
stack will use a locally installed GHC
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
I reinstalled stack and I get the same error after the new installation. So, I don't know what I'm doing wrong. I need it for using atom.
EDIT
Stack.yaml:
# This is the implicit global project's config file, which is only used when
# 'stack' is run outside of a real project. Settings here do _not_ act as
# defaults for all projects. To change stack's default settings, edit
# '/home/chuck/.stack/config.yaml' instead.
#
# For more information about stack's configuration, see
# https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md
#
flags: {}
extra-package-dbs: []
packages: []
extra-deps: []
resolver: lts-8.0
After trying a many things I "found the answer".
The problem was, as epsilonhalbe saw, that I had an old version. So I tried to do this wget -qO- https://get.haskellstack.org/ | sh and it didn't work, because I had stack on /usr/bin/ so, I removed stack and then tried again wget -qO- https://get.haskellstack.org/ | sh. I added $HOME/.local/bin/ to the path, and it's working properly.
I hope it can help someone
EDIT
There's a new version of stack, but ghc-mod just works until the lts-9.0 of stack. So, if you're having troubles with ghc-modand your stack version is over 8.0.2 then:
nano /Users/USERNAME/.stack/global-project/stack.yaml
and replace resolver: --- for resolver: lts-9.0
Then, on the terminal stack solver and it's gonna work :)
I was blocked by the same problem, unless I check which stack (or use where stack as alternative) and I found that I'm using an old version of stack which I installed somehow, and the new version was never accessed when I typed the stack command ...
Here is the situation when I realized the problem..
If you check stack --version and get something like Version 0.1.10.0 x86_64, then it is far away from the current version, the current version I'm using (when answering this question) is Version 1.3.3, Git revision 078cfadeb37a39501eae24732e5c757cc8aca31b x86_64 hpack-0.17.0
If you had confirmed that you are not using the wrong one stack, but the stack version is still too low, you can use stack upgrade --git to upgrade your stack to the latest version from git (notice that this will take a while).
Hope this helpful.

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.

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

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.

Adding blackberry10 platform in cordova(3.0.0) is showing "Error: node cannot be found on the path. Aborting"

I had installed blackberry 10 required software.
Error: node cannot be found on the path. Aborting.
I'm having the same problem. It works when I specify android but not when I specify blackberry10.
As pointed out by Ludivoc above, node is in my path. My command sequence is:
mydir>cordova create test com.example.test Test
mydir>cd test
mydir\test>cordova platform add android
mydir\test>cordova platform add blackberry10
[Error: node cannot be found in path. Aborting.
]
mydir\test>where node
C:\Program Files\nodejs\node.exe
I have also verified that the bbndk is in my path:
mydir\test>where blackberry-signer
C:\bbndk\host_10_1_0_238\win32\x86\usr\bin\blackberry-signer
C:\bbndk\host_10_1_0_238\win32\x86\usr\bin\blackberry-signer.bat
FWIW, I'm running Windows 7 Professional (64bit)
It seems to me that this problem is specific to the cordova scripts for blackberry10 and not to the node installation.
SOLVED: I've had some luck with this problem and there is an answer posted on my thread at http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/lt-img-gt-images-not-being-cached-in-BB10-Webworks-app/m-p/2649771/highlight/false#M41350. The thread actually discusses another problem, but I was able to get this one solved as well (I think:-)). Essentially, you have to make some edits to the init.bat file at C:\Users\.cordova\lib\blackberry10\cordova\3.1.0\bin
We had the same problem and managed to fix it.
The first problem "Error: node cannot be found on the path. Aborting." is related to a file called check_reqs.bat which can be found in the .cordova dir, normally situated in your users home eg. C:\Users\.cordova\lib\blackberry10\cordova\3.1.0\bin\check_reqs.bat
This script tries to check for some files using a variable called %CORDOVA_NODE% e.g.
if not exist "%CORDOVA_NODE%\node.exe" (
No matter what I do, this variable is NEVER set when I call cordova so I just set it by hand
SET %CORDOVA_NODE%=somepath_dont_use_quotes
You might also have to adjust %CORDOVA_BBTOOLS%, on one of our machines it worked, on one it didn't, I was NOT in the mood figuring out why.
The same CORDOVA_NODE issue has to be fixed in your build.bat situated at
\platforms\blackberry10\cordova\build.bat
Last but not least we had a problem in packager.js. There is a logger used in there which gives an error whenever the packager tries to call it so we just put it under comments.
I know this is a little bit of a hack us the %CORDOVA variables should be taken from your system but as those paths shouldn't change we are h appy with the solution.
Open the check_reqs.bat file under C:\Users.cordova\lib\blackberry10\cordova\3.1.0\bin\check_reqs.bat and:
replace %CORDOVA_NODE% with your path to nodejs, mine is C:\Program Files\nodejs.
Then repalce %CORDOVA_BBTOOLS% with the path the blackberry sdk, mine is: C:\bbndk\host_10_2_0_15\win32\x86\usr\bin.
Finally replace the last line "%CORDOVA_NODE%\node" "%~dp0\check_reqs.js" %* by "C:\Program Files\nodejs\node.exe" "%~dp0\check_reqs.js" %*
It works for me
I believe you would get this error if 1) you have not installed node.js or 2) you have installed node.js but not yet added it to your system path.
These two pages provide further detail that may be helpful:
http://cordova.apache.org/docs/en/3.1.0/guide_cli_index.md.html#The%20Command-line%20Interface
http://cordova.apache.org/docs/en/3.1.0/guide_platforms_blackberry10_index.md.html#BlackBerry%2010%20Platform%20Guide
If you install nodejs in the default location, it should be installed in a location that is already in the system path on MacOS
i have updated cordova to 3.2.0,now everything is working fine in win7.
Thank you all
Have u downloaded the Blackberry SDK. You have install the blackberry sdk manually from blackberry's website. only then u can use it in phonegap.
This error occurs in C:\Users\{username}\.cordova\lib\blackberry10\cordova\{version}\bin\init.bat
The fix for me was to add a new environment variable:
Name: CORDOVA_BBTOOLS
Value: C:\Program Files\BlackBerry\BB10 WebWorks SDK 2.2.0.15\cordova-blackberry\bin\dependencies\bb-tools\bin
Your path might not be the exact same. If you can't find it do a search for blackberry-nativepackager.bat and the folder that contains that is the directory you need to set as the value.

Resources