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

Remove indentation for error output #5523

Merged
merged 2 commits into from
Apr 15, 2021
Merged

Conversation

wraithm
Copy link
Contributor

@wraithm wraithm commented Apr 13, 2021

Closes #5430

Indenting the error output of builds makes it so that emacs and vim cannot detect and track errors in the output.

I tested this by running this version of stack inside of my emacs and building a project that produces errors. I confirmed that compilation-mode works with --no-interleaved-output turned on.

Indenting the error output of builds makes it so that emacs and vim
cannot detect and track errors in the output.
@chrisdone
Copy link
Member

Makes sense to me.

@wraithm
Copy link
Contributor Author

wraithm commented Apr 14, 2021

@snoyberg What do you think?

@snoyberg
Copy link
Contributor

Do you have a comparison of how this affects output in the interleaved output case?

@wraithm
Copy link
Contributor Author

wraithm commented Apr 15, 2021

@snoyberg I created this repo to demonstrate the effects of this PR: https://github.com/wraithm/5523-stack-test

The big difference is that emacs/vim can capture the results of the second output and track the errors, but not the first.

Two packages, one with an error in it. The new version doesn't prepend whitespace to the error output. Here are the results with the two different versions of stack:

Old version of stack

$ stack --version
Version 2.5.1, Git revision d6ab861544918185236cf826cb2028abb266d6d5 x86_64 hpack-0.33.0
$ stack build --no-interleaved-output
Building all executables for `bad' once. After a successful build of all of them, only specified executables will be rebuilt.
bad> configure (exe)
bad> build (exe)
Log files have been written to: /path/to/5523-stack-test/.stack-work/logs/

--  While building package bad-0.1.0 (scroll up to its section to see the error) using:
      /home/user/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.4 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0 build exe:bad --ghc-options ""
    Process exited with code: ExitFailure 1
    Logs have been written to: /path/to/5523-stack-test/.stack-work/logs/bad-0.1.0.log

    Configuring bad-0.1.0...
    Preprocessing executable 'bad' for bad-0.1.0..
    Building executable 'bad' for bad-0.1.0..
    [1 of 2] Compiling Main

    /path/to/5523-stack-test/bad/Main.hs:4:47: error:
        lexical error in string/character literal at character '\n'
      |
    4 | main = putStrLn "This is a blatant parse error
      |                                               ^

New version of stack

$ ../stack/stack --version
Version 2.6.0, Git revision 21223c306df528f75e769d1eef5ed4bf8d916129 (8305 commits) PRE-RELEASE x86_64 hpack-0.33.0
$ ../stack/stack build --no-interleaved-output
Building all executables for `bad' once. After a successful build of all of them, only specified executables will be rebuilt.
bad> configure (exe)
bad> build (exe)
Log files have been written to: /path/to/5523-stack-test/.stack-work/logs/

--  While building package bad-0.1.0 (scroll up to its section to see the error) using:
      /home/user/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.4 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0 build exe:bad --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
    Logs have been written to: /path/to/5523-stack-test/.stack-work/logs/bad-0.1.0.log

Configuring bad-0.1.0...
Preprocessing executable 'bad' for bad-0.1.0..
Building executable 'bad' for bad-0.1.0..
[1 of 2] Compiling Main

/path/to/5523-stack-test/bad/Main.hs:4:47: error:
    lexical error in string/character literal at character '\n'
  |
4 | main = putStrLn "This is a blatant parse error
  |                                               ^

@snoyberg
Copy link
Contributor

That all makes sense, but how does it affect things when there is interleaved output?

@wraithm
Copy link
Contributor Author

wraithm commented Apr 15, 2021

When they're interleaved, the output is identical in both cases. Everything has the package name prepended, so errors definitely can't be parsed by emacs/vim there. Honestly, that's a little annoying too, imho, error locations should be on their own line. But the newest version of stack can't produce an output that allows for tracking of errors at all. I don't mind adding --no-interleaved-output.

Here's an example:

$ stack build # old version
Building all executables for `bad' once. After a successful build of all of them, only specified executables will be rebuilt.
bad> configure (exe)
bad> Configuring bad-0.1.0...
bad> build (exe)
bad> Preprocessing executable 'bad' for bad-0.1.0..
bad> Building executable 'bad' for bad-0.1.0..
bad> [1 of 2] Compiling Main
bad> 
bad> /path/to/5523-stack-test/bad/Main.hs:4:47: error:
bad>     lexical error in string/character literal at character '\n'
bad>   |
bad> 4 | main = putStrLn "This is a blatant parse error
bad>   |                                               ^
bad> 

--  While building package bad-0.1.0 (scroll up to its section to see the error) using:
      /home/user/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.4 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0 build exe:bad --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
$ ../stack/stack build # new version
Building all executables for `bad' once. After a successful build of all of them, only specified executables will be rebuilt.
bad> configure (exe)
bad> Configuring bad-0.1.0...
bad> build (exe)
bad> Preprocessing executable 'bad' for bad-0.1.0..
bad> Building executable 'bad' for bad-0.1.0..
bad> [1 of 2] Compiling Main
bad> 
bad> /path/to/5523-stack-test/bad/Main.hs:4:47: error:
bad>     lexical error in string/character literal at character '\n'
bad>   |
bad> 4 | main = putStrLn "This is a blatant parse error
bad>   |                                               ^
bad> 

--  While building package bad-0.1.0 (scroll up to its section to see the error) using:
      /home/user/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.4 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0 build exe:bad --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

@snoyberg
Copy link
Contributor

If it's just changing the non-interleaved case, I don't see an issue. Can you add a changelog entry explaining the change? Then I'll be happy to merge. Thanks!

@wraithm
Copy link
Contributor Author

wraithm commented Apr 15, 2021

Will do.

@wraithm
Copy link
Contributor Author

wraithm commented Apr 15, 2021

@snoyberg Is this a behavior change, other enhancement, or a bug fix?

@wraithm
Copy link
Contributor Author

wraithm commented Apr 15, 2021

I added it as an other enhancement! 👍🏻

@snoyberg
Copy link
Contributor

Enhancement sounds good, thanks!

Copy link
Contributor

@snoyberg snoyberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@snoyberg snoyberg merged commit 49515cb into commercialhaskell:master Apr 15, 2021
@wraithm
Copy link
Contributor Author

wraithm commented Apr 15, 2021

Thank you! 👍🏻

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

Successfully merging this pull request may close these issues.

compilation-mode in emacs no-longer creates links to files on errors/warnings
3 participants