diff --git a/lib/Rainbow/Translate.hs b/lib/Rainbow/Translate.hs
--- a/lib/Rainbow/Translate.hs
+++ b/lib/Rainbow/Translate.hs
@@ -5,7 +5,7 @@
 -- exported from "Rainbow".
 module Rainbow.Translate where
 
-import Control.Exception (try, IOException)
+import Control.Exception (try)
 import Data.ByteString (ByteString)
 import Data.List (intersperse)
 import Data.Text (Text)
@@ -222,16 +222,20 @@
 -- are at least 8 colors available, returns 'toByteStringsColors8'.
 -- Otherwise, returns 'toByteStringsColors0'.
 --
--- If any IO exceptions arise during this process, they are discarded
--- and 'toByteStringsColors0' is returned.
---
+-- If the terminfo database could not be read (that is, if
+-- 'System.Console.Terminfo.Base.SetupTermError' is returned), then return
+-- 'toByteStringsColors0'.
 byteStringMakerFromEnvironment
   :: IO (T.Chunk -> [ByteString] -> [ByteString])
 byteStringMakerFromEnvironment = fmap g (try Terminfo.setupTermFromEnv)
   where
     g (Left e) = toByteStringsColors0
       where
-        _types = e :: IOException
+        -- Previously this caught all IOException.  Now it catches only SetupTermError.
+        -- See
+        -- https://github.com/commercialhaskell/stackage/issues/4994
+        -- Hopefully this will fix this Stackage bug.
+        _types = e :: Terminfo.SetupTermError
     g (Right terminal) =
       case Terminfo.getCapability terminal (Terminfo.tiGetNum "colors") of
         Nothing -> toByteStringsColors0
diff --git a/rainbow.cabal b/rainbow.cabal
--- a/rainbow.cabal
+++ b/rainbow.cabal
@@ -1,13 +1,13 @@
 cabal-version: 1.12
 
--- This file has been generated from package.yaml by hpack version 0.31.1.
+-- This file has been generated from package.yaml by hpack version 0.31.2.
 --
 -- see: https://github.com/sol/hpack
 --
--- hash: a0dd786d4193174131933aaa84515c8a81ceaece927b730a4629b9049c32190f
+-- hash: 837a60ee2540f28dc14f871885d041b7f60038586de137f1f3e495154992b4fe
 
 name:           rainbow
-version:        0.34.2.0
+version:        0.34.2.2
 synopsis:       Print text to terminal with colors and effects
 description:    Please see README.md
 category:       System
@@ -30,6 +30,12 @@
   location: https://github.com/massysett/rainbow
 
 library
+  exposed-modules:
+      Rainbow
+      Rainbow.Translate
+      Rainbow.Types
+  other-modules:
+      Paths_rainbow
   hs-source-dirs:
       lib
   other-extensions: TemplateHaskell
@@ -40,17 +46,17 @@
     , lens
     , terminfo
     , text
-  exposed-modules:
-      Rainbow
-      Rainbow.Translate
-      Rainbow.Types
-  other-modules:
-      Paths_rainbow
   default-language: Haskell2010
 
 test-suite rainbow-instances
   type: exitcode-stdio-1.0
   main-is: rainbow-instances.hs
+  other-modules:
+      Rainbow
+      Rainbow.Translate
+      Rainbow.Types
+      Rainbow.QuickCheck
+      Paths_rainbow
   hs-source-dirs:
       lib
       tests
@@ -63,12 +69,6 @@
     , lens
     , terminfo
     , text
-  other-modules:
-      Rainbow
-      Rainbow.Translate
-      Rainbow.Types
-      Rainbow.QuickCheck
-      Paths_rainbow
   default-language: Haskell2010
 
 test-suite rainbow-visual
