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

runMigrationSilent stomps on the encoding of stderr handle #474

Closed
joeyh opened this issue Sep 9, 2015 · 3 comments
Closed

runMigrationSilent stomps on the encoding of stderr handle #474

joeyh opened this issue Sep 9, 2015 · 3 comments

Comments

@joeyh
Copy link
Contributor

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
Copy link
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
Copy link
Contributor

sol commented Jan 8, 2017

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

merijn added a commit to merijn/persistent that referenced this issue Oct 11, 2019
parsonsmatt pushed a commit that referenced this issue Oct 11, 2019
… broken runMigrationSilent (#971)

* Add safer *Quiet variations of runMigrationSilent

This commit fixes/provides workarounds for: #474, #640, #948, and #966.

* Fix stupid typos in initial patch

* Update ChangeLog with PR number
@parsonsmatt
Copy link
Collaborator

Fixed by #971

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

No branches or pull requests

4 participants