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

Can stack ghci handle spaces in main-is path, on Windows? #2266

Closed
mpilgrem opened this issue Jun 13, 2016 · 16 comments
Closed

Can stack ghci handle spaces in main-is path, on Windows? #2266

mpilgrem opened this issue Jun 13, 2016 · 16 comments

Comments

@mpilgrem
Copy link
Member

mpilgrem commented Jun 13, 2016

On Windows 10, if I do stack new SomeFunc; cd SomeFunc; stack setup; stack build; and then stack ghci an error is reported which suggests to me that perhaps a main-is path with a space is not being handled correctly.

With no space in the path (eg Users folder jsmith), the GHCi startup output of stack ghci includes:

GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Lib              ( C:\Users\jsmith\Documents\Code\Haskell\SomeFunc\src\Lib.hs, interpreted )
Ok, modules loaded: Lib.
[2 of 2] Compiling Main ( C:\Users\jsmith\Documents\Haskell\SomeFunc\app\Main.hs, interpreted )
Ok, modules loaded: Lib, Main.
*Main Lib>

With a space in the path (eg Users folder Jane Smith), the same part of that output has:

GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Lib              ( C:\Users\Jane Smith\Documents\Code\Haskell\SomeFunc\src\Lib.hs, interpreted )
Ok, modules loaded: Lib.
target `C:\Users\Jane' is not a module name or a source file
*Lib Lib>
@sjakobi
Copy link
Member

sjakobi commented Jun 13, 2016

Can you post the output of stack --version?

@mpilgrem
Copy link
Member Author

Yes, it is: Version 1.1.2, Git revision c6dac65e3174dea79df54ce6d56f3e98bc060ecc (3647 commits) x86_64 hpack-0.14.0.

@chrisdone
Copy link
Member

I reproduce this issue on Linux with a space in my file names:

bash-3.2$ stack --version
Version 1.1.3, Git revision 7f7f1a5f67f4ecdd1f3009495f1ff101dd38047e (dirty) (3713 commits) x86_64 hpack-0.14.0
bash-3.2$ stack ghci .
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Using main module: 1. Package `foobar' component exe:foobar-exe with main-is file: /Users/chris/foo bar/foobar/app/Main.hs
Configuring GHCi with the following packages: foobar
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
package flags have changed, resetting and loading new packages...
[1 of 1] Compiling Lib              ( /Users/chris/foo bar/foobar/src/Lib.hs, /Users/chris/foo bar/foobar/.stack-work/odir/Lib.o ) [flags changed]
Ok, modules loaded: Lib.
target ‘/Users/chris/foo’ is not a module name or a source file
Prelude Lib> :q
Leaving GHCi.

@chrisdone chrisdone self-assigned this Jun 15, 2016
@WeeBull
Copy link

WeeBull commented Jun 16, 2016

Probably not a surprise, but I've seen the same thing on Mac OS X

@sjakobi
Copy link
Member

sjakobi commented Jun 22, 2016

This might just be a quoting issue in some kind of ghci loading script:

λ> :load /home/simon/test/bli bla/repro/src/Lib.hs
target `/home/simon/test/bli' is not a module name or a source file
λ> :load "/home/simon/test/bli bla/repro/src/Lib.hs"
[1 of 1] Compiling Lib              ( /home/simon/test/bli bla/repro/src/Lib.hs, interpreted )
Ok, modules loaded: Lib.
(0.02 secs, 4096288 bytes)

@chrisdone
Copy link
Member

Good catch! I hadn't considered that yet!

@chrisdone
Copy link
Member

I think you've nailed it, @sjakobi. Applying the fix now.

@chrisdone
Copy link
Member

@mpilgrem @WeeBull @sjakobi @sjakobi @VitorCBSB Pushed a fix, can you update your stack from master and try again?

@VitorCBSB
Copy link

Thanks for your work, Chris. Unfortunately it didn't seem to work for me, my issue (the one with intero) is still happening.

The funny thing is that calling the stack ghci command on my projects never actually failed to work for me for some reason.

C:\Users\Vitor Coimbra>stack --version
Version 1.1.3, Git revision a9a3dacdfa7b5b42278c6b0677aa142f4d39c46b (3729 commits) x86_64 hpack-0.14.0

@sjakobi
Copy link
Member

sjakobi commented Jun 22, 2016

Works for me on Ubuntu 14.04 with stack ghci!

@mpilgrem
Copy link
Member Author

It did not work for me on Windows 10. stack --version is:

Version 1.1.3, Git revision 823a677230b7cfadaac76fca22ecedd270b35576 x86_64 hpack-0.14.0

The relevant part of the output from stack ghci is now:

GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Lib              ( C:\Users\Jane Smith\Documents\Code\Haskell\SomeFunc\src\Lib.hs, interpreted )
Ok, modules loaded: Lib.
Couldn't read "\"C:\\Users\\Jane Smith\\Documents\\Code\\Haskell\\SomeFunc\\app\\Main.hs\""as String
*Lib Lib>

@chrisdone
Copy link
Member

I'm trying it out on a Windows VM.

@chrisdone
Copy link
Member

Okay, I reproduce on Windows:

Couldn't read ""C:\Users\IEUser\foo bar\foo\app\Main.hs""as String

@chrisdone
Copy link
Member

Well, that's funny. GHCi expects an escaped string:

This is what stack is passing to ghci presently:

*Lib Lib> :!cat C:\Users\IEUser\AppData\Local\Temp\ghci2588\ghci-script
:add Lib
:add "C:\Users\IEUser\foo bar\foo\app\Main.hs"
:module + Lib
*Lib Lib> :add "C:\Users\IEUser\foo bar\foo\app\Main.hs"
Couldn't read "\"C:\\Users\\IEUser\\foo bar\\foo\\app\\Main.hs\""as String

But this works:

*Lib Lib> :add "C:\\Users\\IEUser\\foo bar\\foo\\app\\Main.hs"
[2 of 2] Compiling Main             ( C:\Users\IEUser\foo bar\foo\app\Main.hs, interpreted )
Ok, modules loaded: Lib, Main.

Seems like my quoteFileName function was wrong. I'll make it just be show.

chrisdone added a commit that referenced this issue Jul 1, 2016
@chrisdone
Copy link
Member

Okay, that fixed it!

Closing, @mpilgrem re-open if you encounter it again. 👍

@fth86
Copy link

fth86 commented Dec 24, 2017

I am having the same problem using stack version 1.6.3, ghc 8.2.2: spaces in filenames lead to ghci complaining about "is not a module name or a source file".

I now hotfixed my Emacs Intero implementation to put " quotes around the filename, and that resolved it.

Should Intero by default put quotes around paths when passing them to ghc, or should ghc be able to deal with paths containing spaces even when they are not quoted?

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

8 participants