applied-science / deps-library

Publish deps.edn libraries to Clojars
Eclipse Public License 2.0
52 stars 3 forks source link

error: Premature end of file #1

Closed tiye closed 4 years ago

tiye commented 4 years ago

Following conversation on ClojureVerse.. The code I changed to try 0.3.0 https://github.com/mvc-works/skir/commit/8ecb0d04ac70668c64334cbbc94483f8aa9c4efc

=>> yarn deploy
yarn run v1.19.1
$ clj -A:release
TAG... v0.0.7-a2
20-03-05 03:38:01 ChenYonsMacBook.lan ERROR [garamond.git:15] - Command 'git tag --annotate --message Automatically-generated tag from garamond v0.0.7-a2' returned 128!
20-03-05 03:38:01 ChenYonsMacBook.lan ERROR [garamond.git:19] - stderr: fatal: tag 'v0.0.7-a2' already exists
:tag-error {:code 128, :message nil}
 - tag already exists (v0.0.7-a2), continuing
POM... mvc-works/skir {:mvn/version "0.0.7-a2"}
[Fatal Error] :1:39: Premature end of file.
ERROR:  'Premature end of file.'
Execution error (SAXParseException) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser/parse (AbstractSAXParser.java:1239).
Premature end of file.

Full report at:
/var/folders/08/4fbsxdlx1pdbmlgsbqg3ss3m0000gn/T/clojure-6433489285754562045.edn
{:clojure.main/message
 "Execution error (SAXParseException) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser/parse (AbstractSAXParser.java:1239).\nPremature end of file.\n",
 :clojure.main/triage
 {:clojure.error/class org.xml.sax.SAXParseException,
  :clojure.error/line 1239,
  :clojure.error/cause "Premature end of file.",
  :clojure.error/symbol
  com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser/parse,
  :clojure.error/source "AbstractSAXParser.java",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type javax.xml.transform.TransformerException,
    :message
    "org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 39; Premature end of file.",
    :at
    [com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl
     transform
     "TransformerImpl.java"
     740]}
   {:type org.xml.sax.SAXParseException,
    :message "Premature end of file.",
    :at
    [com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
     parse
     "AbstractSAXParser.java"
     1239]}],
  :trace
  [[com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
    parse
    "AbstractSAXParser.java"
    1239]
   [com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
    parse
    "SAXParserImpl.java"
    643]
   [com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl
    transformIdentity
    "TransformerImpl.java"
    632]
   [com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl
    transform
    "TransformerImpl.java"
    728]
   [com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl
    transform
    "TransformerImpl.java"
    343]
   [clojure.data.xml.jvm.pprint$indent_xml
    invokeStatic
    "pprint.clj"
    27]
   [clojure.data.xml.jvm.pprint$indent_xml invoke "pprint.clj" 23]
   [clojure.data.xml$indent invokeStatic "xml.clj" 158]
   [clojure.data.xml$indent doInvoke "xml.clj" 153]
   [clojure.lang.RestFn invoke "RestFn.java" 425]
   [clojure.lang.AFn applyToHelper "AFn.java" 156]
   [clojure.lang.RestFn applyTo "RestFn.java" 132]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$apply invoke "core.clj" 660]
   [clojure.data.xml$indent_str invokeStatic "xml.clj" 164]
   [clojure.data.xml$indent_str doInvoke "xml.clj" 160]
   [clojure.lang.RestFn invoke "RestFn.java" 410]
   [clojure.tools.deps.alpha.gen.pom$sync_pom
    invokeStatic
    "pom.clj"
    135]
   [clojure.tools.deps.alpha.gen.pom$sync_pom invoke "pom.clj" 123]
   [garamond.pom$create_or_sync_pom_BANG_ invokeStatic "pom.clj" 20]
   [garamond.pom$create_or_sync_pom_BANG_ invoke "pom.clj" 13]
   [garamond.pom$generate_BANG_ invokeStatic "pom.clj" 122]
   [garamond.pom$generate_BANG_ invoke "pom.clj" 117]
   [deps_library.release$pom invokeStatic "release.clj" 62]
   [deps_library.release$pom invoke "release.clj" 58]
   [deps_library.release$main invokeStatic "release.clj" 140]
   [deps_library.release$main doInvoke "release.clj" 100]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$apply invoke "core.clj" 660]
   [deps_library.release$main invokeStatic "release.clj" 146]
   [deps_library.release$main doInvoke "release.clj" 100]
   [clojure.lang.RestFn invoke "RestFn.java" 397]
   [clojure.lang.AFn applyToHelper "AFn.java" 152]
   [clojure.lang.RestFn applyTo "RestFn.java" 132]
   [clojure.core$apply invokeStatic "core.clj" 665]
   [clojure.core$apply invoke "core.clj" 660]
   [deps_library.release$_main invokeStatic "release.clj" 149]
   [deps_library.release$_main doInvoke "release.clj" 148]
   [clojure.lang.RestFn invoke "RestFn.java" 397]
   [clojure.lang.AFn applyToHelper "AFn.java" 152]
   [clojure.lang.RestFn applyTo "RestFn.java" 132]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.core$apply invokeStatic "core.clj" 665]
   [clojure.main$main_opt invokeStatic "main.clj" 514]
   [clojure.main$main_opt invoke "main.clj" 510]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause "Premature end of file."}}

Also the pom.xml file looks a bit strange to me,

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>mvc-works</groupId>
  <artifactId>skir</artifactId>
  <version>0.0.7-a1</version>
  <name>skir</name>
  <dependencies/>
  <repositories/>
<scm>
    <url>https://github.com/mhuebert/deps-library</url>
    <tag>8ecb0d04ac70668c64334cbbc94483f8aa9c4efc</tag>
    <connection>scm:git:git@github.com:mvc-works/skir.git</connection>
    <developerConnection>scm:git:git@github.com:mvc-works/skir.git</developerConnection>
  </scm>
</project>
tiye commented 4 years ago

Tried many times and by reading the stack trace, I think it's happening when there's an existing pom.xml file. The program tries to read it, but somehow got an exception.

https://github.com/workframers/garamond/blob/master/src/garamond/pom.clj#L20

Or probably it's because I don't have a :paths field in my deps.edn...

https://github.com/clojure/tools.deps.alpha/blob/master/src/main/clojure/clojure/tools/deps/alpha/gen/pom.clj#L107-L111

XML is weird.. now the exception's gone, but I got multiple lines of.... 😓

<sourceDirectory>src</sourceDirectory>
<sourceDirectory>src</sourceDirectory>
<sourceDirectory>src</sourceDirectory>
mhuebert commented 4 years ago

Odd. Seems like an upstream thing with garamond's handling of the pom.. did you have an existing pom before?

small note, it looks like your :scm-url is still github/mhuebert/deps-library

tiye commented 4 years ago

Odd. Seems like an upstream thing with garamond's handling of the pom.. did you have an existing pom before?

I published once and a pom.xml stays. I added it to .gitignoreafter that. I thought the file was left there intentionally?

small note, it looks like your :scm-url is still github/mhuebert/deps-library

Oh, I forgot to change it..

mhuebert commented 4 years ago

I published once and a pom.xml stays. I added it to .gitignoreafter that. I thought the file was left there intentionally?

It should be ok either way. I was more wondering if the existing pom.xml could have already been badly formatted in some way. Did you try deleting the existing pom and starting fresh? Can run clj -A:release pom to just run the pom step.

tiye commented 4 years ago

Did you try deleting the existing pom and starting fresh?

yep and that worked.

After I added :paths I think it's already working. Just strangely it's adding a line of <sourceDirectory>src</sourceDirectory> each time I run release...(not reproducing...)

tiye commented 4 years ago

running clj -A:release pom generates a file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>mvc-works</groupId>
  <artifactId>skir</artifactId>
  <version>0.0.7-a1</version>
  <name>skir</name>
  <dependencies/>
  <build>
    <sourceDirectory>src</sourceDirectory>
  </build>
  <repositories/>
<scm>
    <url>https://github.com/mvc-works/skir</url>
    <tag>ceea133b6dec0bbe5c1a608f0cf71fd1dae01440</tag>
    <connection>scm:git:git@github.com:mvc-works/skir.git</connection>
    <developerConnection>scm:git:git@github.com:mvc-works/skir.git</developerConnection>
  </scm>
</project>
mhuebert commented 4 years ago

ok. I can fully reproduce this issue by generating a fresh pom from a deps.edn that does not contain :paths, and generating a pom. That pom won't contain any sourceDirectory and on the next run I will see the Premature end of file error. Then, if I add :paths ["src"], subsequent poms will not throw errors, but keep adding <sourceDirectory> ... </sourceDirectory> entries to the end of the file, not inside of a <build> .. </build>. An immediate solution is to delete the pom and generate a new one with a :paths entry already inside deps.edn.

tiye commented 4 years ago

An immediate solution is to delete the pom and generate a new one with a :paths entry already inside deps.edn.

okay, already doing that~

mhuebert commented 4 years ago

I believe the bug is an upstream issue with garamond/pom: https://github.com/workframers/garamond/issues/8

tiye commented 4 years ago

agreed. is there any plan to validate deps.edn? there's chances people may have typos in EDN files...

mhuebert commented 4 years ago

I'd say that's out of scope for this library but agree it would be useful. In this case I think the bug is really in Garamond, as their explicit intention is to follow what Spom does, and Spom doesn't care if there is no :paths key.

tiye commented 4 years ago

Forgot to ask, does deps-library read configures from deps.edn?

like dependencies specified in deps.edn, when my package depends on those packages, does deps-library read that from deps.edn(or maybe just via pom.xml)? tried and turned out just via pom.xml...

mhuebert commented 4 years ago

It does read from deps.edn, via the sync-pom function of tools.deps.alpha: https://github.com/clojure/tools.deps.alpha/blob/master/src/main/clojure/clojure/tools/deps/alpha/gen/pom.clj#L126