purescript / pursuit

Website for hosting and searching PureScript API documentation
https://pursuit.purescript.org/
Other
170 stars 47 forks source link

Publish new release #470

Closed sigma-andex closed 1 year ago

sigma-andex commented 2 years ago

Could anyone make a new release with the latest changes?

JordanMartinez commented 2 years ago

Thanks for the reminder. I'm working on it.

JordanMartinez commented 2 years ago

I've gotten stuck. I need to build cabal-plan locally with the license-generator flag enabled, but I'm having version conflicts in the dependencies. I'll have to look at this another time.

sigma-andex commented 2 years ago

I also tried to generate the licenses but got the same problem. I haven’t figured out how to build/run this license generator

JordanMartinez commented 1 year ago

We might need to try using cabal rather than stack to build the binary.

andys8 commented 1 year ago

TL;DR

Here is a pull request with the updated LICENSE file: https://github.com/purescript/pursuit/pull/472

cabal-plan: license-plan subcommand not working

Issue: cabal-plan license-report exe:pursuit fails with an error showing it wasn't installed with the license-report flag even if it was (should be default).

We need cabal-plan installed as binary. There were instructions how to do this by cloning the repository and compiling it (with stack). cabal-plan was recently bumped (base) to work with recent GHC versions 9.2 and 9.4. While this was done the currently latest release was broken in a way that disabled the license-report functionality.

I provided a fix for the upstream repository and assume it'll be merged and released. If that's not the case, then checkout my fork instead (for now).

purescript: Dependency issue

@thomashoneyman

The problem with cabal new-build is that there are dependency conflicts with base that I haven't been able to resolve.

This is a different problem, and I assume it is related to the version bounds of base.

In pursuit >4 is okay.

https://github.com/purescript/pursuit/blob/11ea3f6d380a9566d21e2527889126a7abbdffa9/pursuit.cabal#L71

But in pursuit is set quite high (to >=4.16.2.0)

https://github.com/purescript/purescript/blob/0b5a87e08f77ce90884a8696f15ef87d725879c9/purescript.cabal#L133

Now the critical part: base is coupled to ghc (the haskell compiler). This means the minimum allowed version to compile the project should be 9.2.3.

This means if ghc --version on the PATH is not minimum 9.2.3, the dependency can't be solved. And I assume that was the case.

Note that we use resolver: nightly-2022-06-09 in stack.yaml. So all stack commands would use ghc 9.2.3. But cabal used ghc that is on the PATH. (I changed this a bit in the upcoming pull request, but the root cause is mixing cabal and stack).

cabal-plan: Dependency issue

@JordanMartinez

I need to build cabal-plan locally with the license-generator flag enabled, but I'm having version conflicts in the dependencies.

@sigma-andex

I haven’t figured out how to build/run this license generator

The initial instructions in the README said to stack init. Essentially meaning migrating the source project of cabal-plan from cabal to stack. While this can work, it also didn't (at least easily) for me. Therefore I'd just install it with cabal, but make sure the ghc and cabal version is up-to-date. See changed instructions.

cabal-plan binary installation in general

We could also install cabal-plan differently. Either including it in pursuit stack/cabal config as build tool (but this will couple versions even more) or e.g. via nix (haskellPackages.cabal-plan or haskellPackages.cabal-plan_0_7_2_2 in case flag is enabled and up-to-date). Or a stack script. Or a github action so that user's don't have to deal with this.

GHC (stackage)

In general it would be good to move from GHC 9.2.3 to 9.2.4 (because there were issues with the release and 9.2.4 is recommended). We can do this by bumping the stack resolver, ideally both here and in purescript repo.

image

thomashoneyman commented 1 year ago

I deployed the v0.9.3 release, but started seeing these errors on requests to Prelude, among others:

Sep 22 01:36:57 pursuit pursuit[23872]: 22/Sep/2022:01:36:57 +0000 [Error] Invalid JSON in: "/var/www/pursuit/data/verified/purescript-prelude/6.0.1.json", error: "Error in $: At the path: [\"modules\"][16][\"reExports\"][0][\"declarations\"][0][\"info\"][\"type\"]\nArising from an Aeson FromJSON instance:\nparsing [] failed, expected Array, but encountered Null\n" @(pursuit-0.9.3-KrZfeOHe0fnFNN8NwekAxC:Handler.Database src/Handler/Database.hs:123:8)

So I've rolled it back.

andys8 commented 1 year ago

I'm wondering if [\"modules\"][16][\"reExports\"][0][\"declarations\"][0][\"info\"][\"type\"] of verified/purescript-prelude/6.0.1.json is really missing or null. Or if we try to parse garbage data (file missing, corrupted or e.g. html).

JordanMartinez commented 1 year ago

Nate mentioned on Discourse that another change made was the addition of SyntheticApp due to the CSE PR. If that's not being handled here properly, that might explain the errors we were seeing above.

JordanMartinez commented 1 year ago

I explored this a bit more.

  1. I git cloned the pursuit-backups repo
  2. I copied the purescript-prelude directory into ./data/verified
  3. I ran stack exec pursuit
  4. I got this error:
[Error] Invalid JSON in: "./data/verified/purescript-prelude/5.0.1.json",
error: "Error in $: 
At the path: [\"modules\"][16][\"reExports\"][0][\"declarations\"][0][\"info\"][\"type\"]
Arising from an Aeson FromJSON instance:
parsing [] failed, expected Array, but encountered Null
" @(pursuit-0.9.3-CF7NJrQqSQeJH2rO81yUf6:Handler.Database src/Handler/Database.hs:123:8)

Here's what the JSON value looks like at that path (I've omitted irrelevant parts):

{
  "annotation": [],
  "tag": "ForAll",
  "contents": [
    "a",
    { <omitted> },
    null
  ]
}

Thoughts on what's going on here? Was it trying to parse [] and parsed it instead as a Null rather than an empty array?

Here's the corresponding spot where Type () is decoded: https://github.com/purescript/purescript/blob/master/src/Language/PureScript/Types.hs#L338-L345

Potentially related but ()'s FromJson instance was changed to accept any JSON value.

pete-murphy commented 1 year ago

I don't know if it helps narrow the search, but trying to piece together what I've found poking around at this

Only the first two of those seem to be problematic, so if I delete compose and identity and write the result to a new -5.0.2.json file

jq "del(.modules[16].reExports[0].declarations[0,1])" data/verified/purescript-prelude/5.0.1.json > data/verified/purescript-prelude/5.0.2.json

and then run stack exec pursuit I don't see any errors. (Not sure if writing to -5.0.2.json is the best way to debug this, but I do see that same reported error if I only delete one of the declarations.)

Similarly, if I add halogen, I need to delete

jq \
  "del(.modules[0].reExports[5].declarations[21,22,23]) |
   del(.modules[17].reExports[1,2,3].declarations[0])" \
   data/verified/purescript-halogen/6.1.2.json \
   > data/verified/purescript-halogen/6.1.3.json

for the JSON parse to succeed. Those are liftEffect, liftAff, and lift.

pete-murphy commented 1 year ago
diff --git a/src/Language/PureScript/Names.hs b/src/Language/PureScript/Names.hs
index 0564aa23..3a13bef1 100644
--- a/src/Language/PureScript/Names.hs
+++ b/src/Language/PureScript/Names.hs
@@ -292,7 +292,7 @@ instance ToJSON a => ToJSON (Qualified a) where
     BySourcePos ss -> toJSON2 (ss, a)

 instance FromJSON a => FromJSON (Qualified a) where
-  parseJSON v = byModule <|> bySourcePos
+  parseJSON v = byModule <|> bySourcePos <|> byMaybeModuleName'
     where
     byModule = do
       (mn, a) <- parseJSON2 v
@@ -300,6 +300,9 @@ instance FromJSON a => FromJSON (Qualified a) where
     bySourcePos = do
       (ss, a) <- parseJSON2 v
       pure $ Qualified (BySourcePos ss) a
+    byMaybeModuleName' = do
+      (mn, a) <- parseJSON2 v
+      pure $ Qualified (byMaybeModuleName mn) a

 instance ToJSON ModuleName where
   toJSON (ModuleName name) = toJSON (T.splitOn "." name)

seems to fix the JSON parsing (per @hdgarrood's suggestion, if I'm understanding it right)

hdgarrood commented 1 year ago

Yep, that's exactly what I had in mind

JordanMartinez commented 1 year ago

I've just deployed v0.9.4 and verified that docs work again. Thanks all for the help!