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

Inhibit errors from terminal-size #4968

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Other enhancements:

Bug fixes:

* Errors from the `terminal-size` package are now silenced. See
[#4901](https://github.com/commercialhaskell/stack/issues/4901)


## v2.1.3.1

Expand Down
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ dependencies:
- rio
- rio-prettyprint
- semigroups
- silently
- split
- stm
- streaming-commons
Expand Down
6 changes: 5 additions & 1 deletion src/Stack/Runners.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import Stack.Types.Nix (nixEnable)
import Stack.Types.Version (stackMinorVersion, stackVersion, minorVersion)
import System.Console.ANSI (hSupportsANSIWithoutEmulation)
import System.Console.Terminal.Size (size, width)
import System.IO.Silently (hSilence)
import System.IO (stderr)

-- | Ensure that no project settings are used when running 'withConfig'.
withGlobalProject :: RIO Runner a -> RIO Runner a
Expand Down Expand Up @@ -145,8 +147,10 @@ withRunnerGlobal go inner = do
ColorAlways -> return True
ColorAuto -> fromMaybe True <$>
hSupportsANSIWithoutEmulation stderr
-- In certain situations the call to 'size' prints error messages on stderr even when the operation
-- succeeds, so we silence stderr to avoid these errors
termWidth <- clipWidth <$> maybe (fromMaybe defaultTerminalWidth
<$> fmap (fmap width) size)
<$> fmap (fmap width) (hSilence [stderr] size))
pure (globalTermWidth go)
menv <- mkDefaultProcessContext
logOptions0 <- logOptionsHandle stderr False
Expand Down