yamadapc / stack-run

Like cabal run for stack
MIT License
29 stars 10 forks source link

`stack install stack-run` Failed in windows 10(GHC8.2.1) #10

Open codehz opened 6 years ago

codehz commented 6 years ago
        鈥?Couldn't match type 鈥楧istribution.Types.UnqualComponentName.UnqualComponentName鈥?                         with 鈥榌Char]鈥?          Expected type: IO String   
            Actual type: IO                                                                                                                                            
                           Distribution.Types.UnqualComponentName.UnqualComponentName                                                                                  
        鈥?In the expression: findDefault' pr                                                                                                                           
          In a stmt of a 'do' block:                                                                                                                                   
            if e then                                                                                                                                                  
                readFile (pr </> ".stack-work" </> ".stack-run-default")                                                                                               
            else                                                                                                                                                       
                findDefault' pr                                                                                                                                        
          In the expression:                                                                                                                                           
            do pr <- fromMaybe (error "No project root found")                                                                                                         
                       <$> getCabalProjectRootCurrent                                                                                                                  
               e <- doesFileExist (pr </> ".stack-work" </> ".stack-run-default")                                                                                      
               if e then                                                                                                                                               
                   readFile (pr </> ".stack-work" </> ".stack-run-default")                                                                                            
               else                                                                                                                                                    
                   findDefault' pr                                                                                                                                     
       |                                                                                                                                                               
    63 |          else findDefault' pr                                                                                                                                 
       |               ^^^^^^^^^^^^^^^                                                                                                                                 

It seems like there are some broken dependences...

valsaven commented 6 years ago

Confirm. In GHC 8.2.2 too.

sclausen commented 6 years ago

Same here on linux with the same ghc version as @valsaven

mesakomarevich commented 6 years ago

Same issue as above on both macOS High Sierra and WIndows 10 with GHC 8.2.2. I get a longer error message though:

Configuring stack-run-0.1.1.4...
Preprocessing executable 'stack-run' for stack-run-0.1.1.4..
Building executable 'stack-run' for stack-run-0.1.1.4..

/private/var/folders/6n/nrqjtm2j199cvn0_3bqy86k00000gn/T/stack1043/stack-run-0.1.1.4/unix/System/Console/Questioner.hs:4:14: warning:
    -XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS
  |
4 | {-# LANGUAGE OverlappingInstances  #-}
  |              ^^^^^^^^^^^^^^^^^^^^
[1 of 5] Compiling System.Console.Questioner.Autocomplete ( unix/System/Console/Questioner/Autocomplete.hs, .stack-work/dist/x86_64-osx/Cabal-2.0.1.1/build/stack-run/stack-run-tmp/System/Console/Questioner/Autocomplete.o )
[2 of 5] Compiling System.Console.Questioner.Util ( unix/System/Console/Questioner/Util.hs, .stack-work/dist/x86_64-osx/Cabal-2.0.1.1/build/stack-run/stack-run-tmp/System/Console/Questioner/Util.o )
[3 of 5] Compiling System.Console.Questioner.ProgressIndicators ( unix/System/Console/Questioner/ProgressIndicators.hs, .stack-work/dist/x86_64-osx/Cabal-2.0.1.1/build/stack-run/stack-run-tmp/System/Console/Questioner/ProgressIndicators.o )
[4 of 5] Compiling System.Console.Questioner ( unix/System/Console/Questioner.hs, .stack-work/dist/x86_64-osx/Cabal-2.0.1.1/build/stack-run/stack-run-tmp/System/Console/Questioner.o )
[5 of 5] Compiling Main             ( src/Main.hs, .stack-work/dist/x86_64-osx/Cabal-2.0.1.1/build/stack-run/stack-run-tmp/Main.o )

/private/var/folders/6n/nrqjtm2j199cvn0_3bqy86k00000gn/T/stack1043/stack-run-0.1.1.4/src/Main.hs:63:15: error:
    • Couldn't match type ‘Distribution.Types.UnqualComponentName.UnqualComponentName’
                     with ‘[Char]’
      Expected type: IO String
        Actual type: IO
                       Distribution.Types.UnqualComponentName.UnqualComponentName
    • In the expression: findDefault' pr
      In a stmt of a 'do' block:
        if e then
            readFile (pr </> ".stack-work" </> ".stack-run-default")
        else
            findDefault' pr
      In the expression:
        do pr <- fromMaybe (error "No project root found")
                   <$> getCabalProjectRootCurrent
           e <- doesFileExist (pr </> ".stack-work" </> ".stack-run-default")
           if e then
               readFile (pr </> ".stack-work" </> ".stack-run-default")
           else
               findDefault' pr
   |
63 |          else findDefault' pr
   |               ^^^^^^^^^^^^^^^

/private/var/folders/6n/nrqjtm2j199cvn0_3bqy86k00000gn/T/stack1043/stack-run-0.1.1.4/src/Main.hs:84:5: error:
    • Couldn't match type ‘Distribution.Types.UnqualComponentName.UnqualComponentName’
                     with ‘[Char]’
      Expected type: IO [String]
        Actual type: IO
                       [Distribution.Types.UnqualComponentName.UnqualComponentName]
    • In a stmt of a 'do' block: return $ getExecutables pkgParseResult
      In the expression:
        do pr <- fromMaybe (error "No project root found")
                   <$> getCabalProjectRootCurrent
           cfp <- fromMaybe (error "No cabal file found")
                    <$>
                      (find ((== ".cabal") . takeExtension) <$> getDirectoryContents pr)
           pkgParseResult <- getPackageDescription (pr </> cfp)
           return $ getExecutables pkgParseResult
      In an equation for ‘getExecutables’:
          getExecutables
            = do pr <- fromMaybe (error "No project root found")
                         <$> getCabalProjectRootCurrent
                 cfp <- fromMaybe (error "No cabal file found")
                          <$>
                            (find ((== ".cabal") . takeExtension) <$> getDirectoryContents pr)
                 pkgParseResult <- getPackageDescription (pr </> cfp)
                 ....
            where
                getPackageDescription p = parsePackageDescription <$> readFile p
                getExecutables (ParseFailed _) = error "Failed to parse cabal file"
                getExecutables (ParseOk _ gpd)
                  = case condExecutables gpd of
                      [] -> error "No executables found"
                      ds -> map fst ds
   |
84 |     return $ getExecutables pkgParseResult
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^`
kgadek commented 6 years ago

There's a PR that shall fix the thing. Meanwhile, I've used the following workaround for stack project, it allows to do e.g. stack build stack-run.

preparations

mkdir -p vendor
cd vendor
stack unpack stack-run-0.1.1.4

project's stack.yaml

packages:
  - '.'
  - location: vendor/stack-run-0.1.1.4
    extra-dep: true

my ugly patch (strictly worse than @mspaulding06's PR #11 )

diff --git a/src/Main.hs b/src/Main.hs
index 2d6de8b..f9f879b 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -16,6 +16,7 @@ import           Data.Maybe
 import           Data.Time
 import           Distribution.PackageDescription
 import           Distribution.PackageDescription.Parse
+import           Distribution.Types.UnqualComponentName
 import           System.Console.ANSI
 #ifndef OS_Win32
 import           System.Console.Questioner
@@ -60,7 +61,7 @@ findDefault = do
         getCabalProjectRootCurrent
     e <- doesFileExist (pr </> ".stack-work" </> ".stack-run-default")
     if e then readFile (pr </> ".stack-work" </> ".stack-run-default")
-         else findDefault' pr
+         else unUnqualComponentName <$> findDefault' pr
   where
     findDefault' pr = do
         cfp <- fromMaybe (error "No cabal file found") <$>
@@ -81,7 +82,7 @@ getExecutables = do
     cfp <- fromMaybe (error "No cabal file found") <$>
         (find ((== ".cabal") . takeExtension) <$> getDirectoryContents pr)
     pkgParseResult <- getPackageDescription (pr </> cfp)
-    return $ getExecutables pkgParseResult
+    return . fmap unUnqualComponentName $ getExecutables pkgParseResult
   where
     getPackageDescription p = parsePackageDescription <$> readFile p
     getExecutables (ParseFailed _) =
diff --git a/stack-run.cabal b/stack-run.cabal
index a06c784..35449a0 100644
--- a/stack-run.cabal
+++ b/stack-run.cabal
@@ -29,7 +29,7 @@ executable stack-run
                      , base >=4 && <5
                      , bytestring >= 0.10
                      , conduit > 1.1 && < 1.3
-                     , conduit-extra >= 1.1 && < 1.2
+                     , conduit-extra >= 1.2 && < 1.3
                      , directory
                      , filepath
                      , time >= 1.5.0.1
mjkramer commented 6 years ago

To elaborate on kgadek's answer, here's a newbie guide to doing a "global" install of stack-run while this issue remains:

mkdir build-stack-run
cd build-stack-run
stack unpack stack-run-0.1.1.4

Paste kgadek's patck into fix.patch, and then:

patch -p 1 -d stack-run-0.1.1.4 -i ../fix.patch
stack init # note: I used --resolver=nightly-2018-01-01 but the default should work
stack install

At which point stack-run should appear in ~/.local/bin.

keremispirli commented 6 years ago

@kgadek I created stack.yaml in project folder, next to stack-run.cabal:

resolver: lts-11.0

packages:
  - '.'
  - location: "."
    extra-dep: true

I keep getting this error message when I run stack install:

The same package name is used in multiple local packages

stack-run used in:
- PLOther (PLFilePath ".")
- PLOther (PLFilePath ".")

Tried to remove existing package but couldn't find it with ghc-pkg list Any ideas?

XertroV commented 5 years ago

In case anyone finds this, I have a workaround that works on macos, though not sure about windows: https://github.com/yamadapc/stack-run/issues/17#issuecomment-427545735

Magicloud commented 5 years ago

Please check if pull request #22 fixes your problem.

jnials commented 5 years ago

Same problem here. Not conversant enough in Haskell building to figure out how to fix this.