【问题标题】:Yesod ExitFailure 1 when installing scaffolded appYesod ExitFailure 1 安装脚手架应用程序时
【发布时间】:2013-03-05 02:24:18
【问题描述】:

我正在尝试安装我的第一个脚手架 Yesod 应用程序。当我运行 cabal-dev install && yesod --dev devel 时,它会因 ExitFailure 1 而失败。我正在使用 sqlite 进行持久化。

Application.hs:49:44:
No instance for (monad-logger-0.3.1:Control.Monad.Logger.MonadLogger
                   IO)
  arising from a use of `runMigration'
Possible fix:
  add an instance declaration for
  (monad-logger-0.3.1:Control.Monad.Logger.MonadLogger IO)
In the second argument of `Database.Persist.Store.runPool', namely
  `(runMigration migrateAll)'
In a stmt of a 'do' block:
  Database.Persist.Store.runPool dbconf (runMigration migrateAll) p
In the expression:
  do { manager <- newManager def;
       s <- staticSite;
       dbconf <- withYamlEnvironment
                   "config/sqlite.yml" (appEnv conf) Database.Persist.Store.loadConfig
                 >>= Database.Persist.Store.applyEnv;
       p <- Database.Persist.Store.createPoolConfig
              (dbconf :: PersistConfig);
       .... }
Failed to install testProject-0.0.0
cabal.exe: Error: some packages failed to install:
testProject-0.0.0 failed during the building phase. The exception was:
ExitFailure 1

我已尝试按照此处的说明进行操作:http://www.yesodweb.com/book/scaffolding-and-the-site-template 尚未设法找到有关此问题的任何信息。关于缺少什么的任何线索?

【问题讨论】:

    标签: haskell yesod


    【解决方案1】:

    错误消息显示缺少MonadLogger IO 实例。问题是monad-logger的安装版本太新了。 monad-logger-0.2.4includes the instance你需要,monad-logger-0.3.0及以上apparently don't

    解决办法: 将&amp;&amp; &lt; 0.3.0 添加到您的cabal 文件中的monad-logger 行,然后再次执行cabal install --only-dependencies

    (如果没有monad-logger这一行,添加一个类似, monad-logger &lt; 0.3.0

    【讨论】:

      【解决方案2】:

      使用Control.Monad.Logger 中的runFooLoggingT 函数之一。特别是runNoLoggingT

      这可能比将自己固定在旧版本的库中要好得多!

      【讨论】:

      • 我在尝试编译this page 上的电子邮件身份验证示例时遇到了一个相关的(我认为)编译错误。编译错误是“由于使用 `runMigration' 而导致 (Control.Monad.Logger.MonadLogger IO) 没有实例。如果您认为这会有所帮助,您能否提供一些关于在该代码中插入 runNoLoggingT 的位置的提示?我”我猜测它在页面底部的 main 中某处,不确定在哪里。
      • 把 runNoLoggingT 放在 main 的前面就可以了。这是编译的主要内容:`main
      • Ran out of time on previous comment.... 将 runNoLoggingT 放在我链接到的源代码的 main 前面就可以了。我还需要在 warpDebug 之前添加一个 liftIO。我会在此处粘贴固定代码供其他人查看,但我不知道如何将代码粘贴到评论中。感谢 Colin 的大提示!
      【解决方案3】:

      我仍然对变形金刚感到满意,所以 按照 Colin 的回答,这是一种完全禁用日志记录的非常快速的方法:

      import Control.Monad.Logger (MonadLogger, monadLoggerLog)
      import Control.Applicative  (pure)
      
      instance MonadLogger IO where
          monadLoggerLog _ _ _ = pure $ pure ()
      

      它基本上为MonadIO 重新实现了NoLoggingT 实例。

      但是,一旦您对代码库进行了快速修复,您应该像我现在所做的那样前往 Haskell Wiki 的 Monad Transformers 页面; )

      【讨论】:

        【解决方案4】:

        仅供参考,我通过将提供给withSqliteConn 的值包装为NoLoggingT 构造函数的参数来克服这个问题,这允许withSqliteConn 在堆栈中的某处找到MonadLogger,然后我用@987654325 解开返回的结果@

        mainWithExplicitConnection2:: IO ()
        mainWithExplicitConnection2 =
            runNoLoggingT $ withSqliteConn ":memory:" $ \conn ->
                NoLoggingT $ flip runSqlPersistM conn $ runMigration migrateAll
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-06-17
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-07-27
          • 1970-01-01
          • 2018-01-11
          相关资源
          最近更新 更多