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

runMigrationSilent stomps on the encoding of stderr handle #474

Open
joeyh opened this Issue Sep 9, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@joeyh

joeyh commented Sep 9, 2015

This transcript shows a really strange side effect, and surely it's a bug this happens:

*Database.Fsck Database.Handle> hSetEncoding stderr utf16
*Database.Fsck Database.Handle> hGetEncoding stderr
Just UTF-16
*Database.Fsck Database.Handle> initDb "/tmp/testdb" $ void $ runMigrationSilent  migrateFsck 
*Database.Fsck Database.Handle> hGetEncoding stderr
Just UTF-8

stdout's encoding is not effected, only stderr.

I'm using persistent-2.1.6 and persistent-sqlite-2.1.4.2, with ghc 7.8.4.

In case it matters somehow, here's the TH code that generated the migration:

share [mkPersist sqlSettings, mkMigrate "migrateFsck"] [persistLowerCase|
  Fscked
    key SKey
    UniqueKey key
  |]
newtype SKey = SKey String
    deriving (Show, Read)
@gregwebs

This comment has been minimized.

Member

gregwebs commented Sep 9, 2015

Can you send this report upstream?

import System.IO.Silently (hSilence)
runMigrationSilent m = liftBaseOp_ (hSilence [stderr]) $ runMigration' m True
@sol

This comment has been minimized.

Contributor

sol commented Jan 8, 2017

In general, I think it would be more robust to not rely on silently to control verbosity.

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