JPMoresmau / scion-class-browser

Scion part for EclipseFP Class Browser
16 stars 6 forks source link

Rebuilding local database has encountered a problem #18

Open habbler opened 9 years ago

habbler commented 9 years ago

Hello,

Any idea what might be causing

Error loading local database Removing ["wl-pprint-text","warp","wai","void","vector-algorithms","vector","vault","utf8-string","unordered-containers","unix-compat","transformers-compat","transformers-base","transformers","tls","text-stream-decode","text","temporary","tar","tagsoup","tagged","syb","streaming-commons","stm","spoon","split","simple-sendfile","shake","semigroups","semigroupoids","securemem","scientific","sbv","safe","resourcet","resource-pool","reflection","random","quickspec","profunctors","primitive","polyparse","path-pieces","parsec","parallel","network-uri","network","nats","mwc-random","mtl","monad-loops","monad-control","mmorph","lifted-base","lens","js-jquery","js-flot","iproute","HUnit","http-client","hscolour","hoogle","hlint","haskell-generate","haskeline","hashable","graphviz","free","fgl","fast-logger","extra","dynamic-cabal","dlist","distributive","crypto-pubkey","cprng-aes","cpphs","contravariant","connection","conduit","comonad","colour","cmdargs","Cabal","bytestring-builder","bytestring","byteorder","buildwrapper","blaze-markup","blaze-html","blaze-builder","bifunctors","base-unicode-symbols","attoparsec","appar","ansi-terminal","aeson"] Adding ["void","vector","utf8-string","unordered-containers","transformers-base","transformers","tls","text","tar","syb","streaming-commons","stm","semigroups","securemem","scientific","resourcet","resource-pool","random","primitive","polyparse","path-pieces","parsec","network","nats","mtl","monad-loops","monad-control","mmorph","lifted-base","http-client","haskell-generate","haskeline","hashable","fast-logger","dynamic-cabal","dlist","crypto-pubkey","cpphs","connection","conduit","cmdargs","bytestring-builder","buildwrapper","blaze-markup","blaze-html","blaze-builder","attoparsec","aeson","Cabal","bytestring"] scion-browser.exe: TypeDecodingFailed "time format invalid for TimeUTC : cannot convert string 0007181000Z"

I have not been able to reproduce this by executing scion-browser directly from the shell. Maybe it has to be executed in a specific directory?

Deleting the user cabal directory and user package database and rebuilding the user packages and package database and scion-browser also didn't help.

This is on ghc-7.6.3

Rene.

JPMoresmau commented 9 years ago

Never seen that error. It comes from the asn1-encoding package, that scion-browser doesn't use directly, so it's an indirect dependency: we use something that parses some asn1 and fails.

habbler commented 9 years ago

Hmmm. Must come from simpleHTTP which is used by getFileLazy / getFileStrict Maybe our proxy does something to the X509 certificates dates. Is there anyway I can persuade scion-browser not to try downloading anything from the internet? In fact I am surprised that it is, as I don't have the download from hackage check-box checked.

JPMoresmau commented 9 years ago

Makes sense. scion-browser always tries to download files. The hackage option is just to switch between "index only the packages I have installed" and "index everything on Hackage". I suppose we should just catch exceptions better when downloading.

JPMoresmau commented 9 years ago

I've pushed a change, if you can build from source and test: https://github.com/JPMoresmau/scion-class-browser/commit/e3927dd063fcd478783f0432a5d81bda045dbeb2

habbler commented 9 years ago

The following program reproduces the problem

import Network.HTTP.Conduit import Data.ByteString.Lazy

hoogleDbUrl = "http://hackage.haskell.org/packages/archive/00-hoogle.tar.gz"

test :: IO ByteString test = simpleHttp hoogleDbUrl

Hmm, I wonder if simpleHTTP doesn't respect the environment variable HTTP_PROXY. An older version of scion-browser used to work, but I think older versions did not use simpleHttp ?

Rene.

habbler commented 9 years ago

I still get the exception with e3927dd.

It looks like it would not be hard to read environment variable HTTP_PROXY, and copy the coding of simpleHttp to set a proxy server if there is one.

Rene.

habbler commented 9 years ago

So for some reason the catch you added to downloadHoogleFile has no effect (I wrote a small test program to verify this). I have no idea way. I have also not managed to write a version that works. In downloadFileLazy the catch works as expected.

habbler commented 9 years ago

It seems that the catch needs to come outside of runResourceT to work. For instance

test4 = withSocketsDo $ do req <- parseUrl hoogleDbUrl ((fmap Just (withManager $ httpLbs req)) catch (_ :: SomeException)->return Nothing ) successfully catches the exception.

where

withManager :: ResourceIO m => (Manager -> ResourceT m a) -> m a withManager f = runResourceT $ do (_, manager) <- withIO (newManager def) closeManager f manager

habbler commented 9 years ago

Mystery (half) solved!!!!

test5 :: IO Int test5 = withManager $ \mgr -> return 2

test5 *\ Exception: TypeDecodingFailed "time format invalid for TimeUTC : cannot convert string 0007181000Z" the exception is being raised in withManager.