Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack setup fails for ghcjs project on windows #1774

Closed
martin-kolinek opened this issue Feb 10, 2016 · 11 comments
Closed

Stack setup fails for ghcjs project on windows #1774

martin-kolinek opened this issue Feb 10, 2016 · 11 comments

Comments

@martin-kolinek
Copy link
Contributor

stack setup fails when executed in a project setup for ghcjs like this:

compiler: ghcjs-0.2.0.20151230.3_ghc-7.10.2
compiler-check: match-exact
setup-info:
 ghcjs:
  source:
   ghcjs-0.2.0.20151230.3_ghc-7.10.2:
    url: "https://github.com/nrolland/ghcjs/releases/download/v.0.2.0.20151230.3/ghcjs-0.2.0.20151230.3.tar.gz"

The error is Expected a single directory within unpacked ..., and happens on windows.

Steps to reproduce

  1. Have a windows system without ghcjs installed
  2. Create a project with stack.yaml such as this one (based on the guide)
  3. Run stack setup

Expected:
Stack sets up ghcjs

Actual
Stack fails with Expected a single directory within unpacked ...

Whole output:

Preparing to install GHCJS to an isolated location.
This will not interfere with any system-level installation.
Preparing to download ghcjs-0.2.0.20151230.3_ghc-7.10.2 ...
No sha1 found in metadata, download hash won't be checked.
Preparing to download ghcjs-0.2.0.20151230.3_ghc-7.10.2 ...
Already downloaded.
Unpacking GHCJS into C:\Users\kot\AppData\Local\Programs\stack\x86_64-windows\ghcjs-0.2.0.20151230.3_ghc-7.10.2\src\ 
Preparing to download 7z.dll ...
Already downloaded.
Preparing to download 7z.exe ...Already downloaded.
Expected a single directory within unpacked C:\Users\kot\AppData\Local\Programs\stack\x86_64-windows\ghcjs-0.2.0.20151230.3_ghc-7.10.2.tar.gz

Output of stack --version:

Version 1.0.2, Git revision fa09a980d8bb3df88b2a9193cd9bf84cc6c419b3 (3084 commits) x86_64

I attached the output of stack setup --verbose

mgsloan added a commit that referenced this issue Feb 10, 2016
Fix withUnpackedTarball7z to find name of srcDir after unpacking #1774
@mgsloan
Copy link
Contributor

mgsloan commented Feb 11, 2016

Doh! Thanks for finding and fixing this :D

@RaoulSchaffranek
Copy link

Unfortunately, the bug seems to have sneaked in again with version 1.6.3:

stack --version
Version 1.6.3, Git revision b27e629b8c4ce369e3b8273f04db193b060000db (5454 commits) x86_64 hpack-0.20.0
# stack.yaml
resolver: lts-6.20
compiler: ghcjs-0.2.0.9006020_ghc-7.10.3
compiler-check: match-exact

packages:
 - '.'
extra-deps: []

setup-info:
  ghcjs:
    source:
      ghcjs-0.2.0.9006020_ghc-7.10.3:
         url: http://ghcjs.tolysz.org/lts-6.20-9006020.tar.gz
         sha1: a6cea90cd8121eee3afb201183c6e9bd6bacd94a

The steps to reproduce are exactly the same as above, the whole error-message reads:

Control.Exception.Safe.throwString called with:

Expected a single directory within unpacked C:\Users\Raoul\AppData\Local\Programs\stack\x86_64-windows\ghcjs-0.2.0.9006030_ghc-7.10.3.tar.gz
Called from:
  throwString (src/Stack\Setup.hs:1416:14 in stack-1.6.3-F6YVX3qh2MsHZufmhdWM8J:Stack.Setup)

The exception is thrown from this line https://github.com/commercialhaskell/stack/blob/v1.6.3/src/Stack/Setup.hs#L1416

@mgsloan mgsloan reopened this Jan 11, 2018
@mgsloan
Copy link
Contributor

mgsloan commented Jan 11, 2018

@RaoulSchaffranek Huh, that's curious. Perhaps it's an issue with that particular tarball. Setup.hs hasn't changed much recently. Only thing that's GHCJS related is bc9007a and that's a change for booting which comes after installing from the tarball.

@RaoulSchaffranek
Copy link

I tried several other tarballs and it remains the same story. After running stack setup i end up with a weird directory-structure in C:\Users\Raoul\AppData\Local\Programs\stack\x86_64-windows:

ghcjs-0.2.0.9006020_ghc-7.10.3
ghcjs-0.2.0.9006020_ghc-7.10.3.temp
ghcjs-0.2.0.9006020_ghc-7.10.3.tar.gz
7z.dll
7z.exe

Where the directories ghcjs-0.2.0.9006020_ghc-7.10.3 and ghcjs-0.2.0.9006020_ghc-7.10.3.temp are both empty. However, I can unpack the tarball manually, so the archive seems to be working in general.

@mgsloan
Copy link
Contributor

mgsloan commented Jan 12, 2018

Curious! Things changed here - #3212 - but I verified with a windows user that the change works. Can you please try without that change to see if that's the culprit? I don't currently have access to a windows setup. Extra awesome bonus points would be to open a PR with a fix!

@dwaldhalm
Copy link
Contributor

I'm able to get it working on my fresh Windows 10 installation by easing the expectation for the single unpacked directory in Setup.hs. expectSingleUnpackedDir fails when contents has to be ([dir], [] ), but works when it can be ([dir], _). I think the .tar file is still in the directory.

I can make a pull request if that suits you.

expectSingleUnpackedDir :: (MonadIO m, MonadThrow m) => Path Abs File -> Path Abs Dir -> m (Path Abs Dir)
expectSingleUnpackedDir archiveFile destDir = do
    contents <- listDir destDir
    case contents of
        ([dir], _ ) -> return dir
        _ -> throwString $ "Expected a single directory within unpacked " ++ toFilePath archiveFile

@mgsloan
Copy link
Contributor

mgsloan commented Jan 18, 2018

@dwaldhalm Sure, a PR would be appreciated, thanks!

@dwaldhalm
Copy link
Contributor

#3794

@Rizary
Copy link

Rizary commented Mar 1, 2018

it also happened to me when using this ghcjs compiler
https://github.com/matchwood/ghcjs-stack-dist

can i just change to ([dir], _) ?

@mgsloan
Copy link
Contributor

mgsloan commented Mar 2, 2018

@Rizary I don't think @dwaldhalm 's fix has been included in a released version of stack yet. You can do stack upgrade --git to build the development version of stack from source.

Closing this issue, hopefully it is solved by that fix. If not, feel free to re-open or request it be reopened.

@mgsloan mgsloan closed this as completed Mar 2, 2018
@ShadowManu
Copy link

ShadowManu commented Apr 4, 2018

Happening to me, just installing Stack and trying to follow the instructions at https://docs.haskellstack.org/en/stable/ghcjs/. Any workaround I can do?

Control.Exception.Safe.throwString called with:

Expected a single directory within unpacked C:\Users\ShadowManu\AppData\Local\Programs\stack\x86_64-windows\ghcjs-0.2.1.9007019_ghc-8.0.1.tar.gz
Called from:
  throwString (src/Stack\Setup.hs:1416:14 in stack-1.6.5-C76csly8kVr6AoLZgFLNjb:Stack.Setup)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants