asciidoctor / asciidoctor-gradle-plugin

A Gradle plugin that uses Asciidoctor via JRuby to process AsciiDoc source files within the project.
https://asciidoctor.github.io/asciidoctor-gradle-plugin/
Apache License 2.0
285 stars 120 forks source link

`org.jruby.exceptions.LoadError: (LoadError) no such file to load` on `RubyKernel.require`, possibly related to Gradle build-cache #628

Open bric3 opened 2 years ago

bric3 commented 2 years ago

For no reason gradle build started to fail with a load error, I don't quite understand what's wrong. I didn't changed anything in the buildscript.

$ ./gradlew build

> Task :2021-11-09-ParisJug-Panama:asciidoctorRevealJs
Exception in thread "main" org.jruby.exceptions.LoadError: (LoadError) no such file to load -- asciidoctor-revealjs
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:974)
        at uri_3a_classloader_3a_.META_minus_INF.jruby_dot_home.lib.ruby.stdlib.rubygems.core_ext.kernel_require.require(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:83)
        at RUBY.<main>(<script>:1)

> Task :2021-11-09-ParisJug-Panama:asciidoctorRevealJs FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':2021-11-09-ParisJug-Panama:asciidoctorRevealJs'.
> Remote Asciidoctor process failed to complete successfully

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
2 actionable tasks: 1 executed, 1 up-to-date
$ ./gradlew :2021-11-09-ParisJug-Panama:buildEnvironment

> Task :2021-11-09-ParisJug-Panama:buildEnvironment

------------------------------------------------------------
Project ':2021-11-09-ParisJug-Panama'
------------------------------------------------------------

classpath
\--- org.asciidoctor.jvm.revealjs:org.asciidoctor.jvm.revealjs.gradle.plugin:3.3.2
     \--- org.asciidoctor:asciidoctor-gradle-jvm-slides:3.3.2
          +--- org.ysb33r.gradle:grolifant:0.16.1
          |    \--- org.tukaani:xz:1.6
          +--- org.asciidoctor:asciidoctor-gradle-base:3.3.2
          |    \--- org.ysb33r.gradle:grolifant:0.16.1 (*)
          \--- org.asciidoctor:asciidoctor-gradle-jvm-gems:3.3.2
               +--- org.ysb33r.gradle:grolifant:0.16.1 (*)
               +--- com.github.jruby-gradle:jruby-gradle-core-plugin:2.0.2
               |    +--- org.ysb33r.gradle:grolifant:0.12 -> 0.16.1 (*)
               |    +--- io.github.http-builder-ng:http-builder-ng-okhttp:1.0.3
               |    |    +--- io.github.http-builder-ng:http-builder-ng-core:1.0.3
               |    |    |    +--- xml-resolver:xml-resolver:1.2
               |    |    |    \--- org.slf4j:slf4j-api:1.7.21 -> 1.7.25
               |    |    +--- com.squareup.okhttp3:okhttp:3.4.2 -> 3.5.0
               |    |    |    \--- com.squareup.okio:okio:1.11.0
               |    |    \--- com.burgstaller:okhttp-digest:1.10
               |    |         \--- com.squareup.okhttp3:okhttp:3.5.0 (*)
               |    \--- io.ratpack:ratpack-core:1.6.1
               |         +--- io.ratpack:ratpack-exec:1.6.1
               |         |    +--- io.ratpack:ratpack-base:1.6.1
               |         |    |    +--- com.google.guava:guava:21.0
               |         |    |    \--- org.slf4j:slf4j-api:1.7.25
               |         |    +--- org.slf4j:slf4j-api:1.7.25
               |         |    +--- io.netty:netty-buffer:4.1.32.Final
               |         |    |    \--- io.netty:netty-common:4.1.32.Final
               |         |    +--- io.netty:netty-transport-native-epoll:4.1.32.Final
               |         |    |    +--- io.netty:netty-common:4.1.32.Final
               |         |    |    +--- io.netty:netty-buffer:4.1.32.Final (*)
               |         |    |    +--- io.netty:netty-transport-native-unix-common:4.1.32.Final
               |         |    |    |    +--- io.netty:netty-common:4.1.32.Final
               |         |    |    |    \--- io.netty:netty-transport:4.1.32.Final
               |         |    |    |         +--- io.netty:netty-buffer:4.1.32.Final (*)
               |         |    |    |         \--- io.netty:netty-resolver:4.1.32.Final
               |         |    |    |              \--- io.netty:netty-common:4.1.32.Final
               |         |    |    \--- io.netty:netty-transport:4.1.32.Final (*)
               |         |    \--- org.reactivestreams:reactive-streams:1.0.2
               |         +--- io.netty:netty-codec-http:4.1.32.Final
               |         |    \--- io.netty:netty-codec:4.1.32.Final
               |         |         \--- io.netty:netty-transport:4.1.32.Final (*)
               |         +--- io.netty:netty-handler:4.1.32.Final
               |         |    +--- io.netty:netty-buffer:4.1.32.Final (*)
               |         |    +--- io.netty:netty-transport:4.1.32.Final (*)
               |         |    \--- io.netty:netty-codec:4.1.32.Final (*)
               |         +--- com.sun.activation:javax.activation:1.2.0
               |         +--- com.github.ben-manes.caffeine:caffeine:2.6.2
               |         +--- org.javassist:javassist:3.22.0-GA
               |         +--- com.fasterxml.jackson.core:jackson-databind:2.9.8
               |         |    +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0
               |         |    \--- com.fasterxml.jackson.core:jackson-core:2.9.8
               |         +--- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.8
               |         |    \--- com.fasterxml.jackson.core:jackson-core:2.9.8
               |         +--- com.fasterxml.jackson.datatype:jackson-datatype-guava:2.9.8
               |         |    +--- com.fasterxml.jackson.core:jackson-core:2.9.8
               |         |    \--- com.fasterxml.jackson.core:jackson-databind:2.9.8 (*)
               |         +--- org.yaml:snakeyaml:1.23
               |         +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.8
               |         |    +--- com.fasterxml.jackson.core:jackson-core:2.9.8
               |         |    \--- com.fasterxml.jackson.core:jackson-databind:2.9.8 (*)
               |         \--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.8
               |              +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0
               |              +--- com.fasterxml.jackson.core:jackson-core:2.9.8
               |              \--- com.fasterxml.jackson.core:jackson-databind:2.9.8 (*)
               \--- org.asciidoctor:asciidoctor-gradle-jvm:3.3.2
                    +--- org.ysb33r.gradle:grolifant:0.16.1 (*)
                    \--- org.asciidoctor:asciidoctor-gradle-base:3.3.2 (*)

(*) - dependencies omitted (listed previously)

A web-based, searchable dependency report is available by adding the --scan option.

BUILD SUCCESSFUL in 777ms
1 actionable task: 1 executed
$ ./gradlew --version

------------------------------------------------------------
Gradle 7.0.2
------------------------------------------------------------

Build time:   2021-05-14 12:02:31 UTC
Revision:     1ef1b260d39daacbf9357f9d8594a8a743e2152e

Kotlin:       1.4.31
Groovy:       3.0.7
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          11.0.12 (Amazon.com Inc. 11.0.12+7-LTS)
OS:           Mac OS X 11.6 x86_64
bric3 commented 2 years ago

Oh by the way here's the build descriptor

plugins {
    id("org.asciidoctor.jvm.revealjs") version "3.3.2"
}

// keep using the groovy DSL otherwise ruby.gem() will raise an "Unresolved reference"
repositories {
    mavenCentral()
    ruby.gems()
}

// Speaker mode: type `s`
// Fullscreen mode: type `o`
// Fullscreen mode: type `f`

// See https://asciidoctor.github.io/asciidoctor-gradle-plugin/development-3.x/user-guide/#asciidoctorj-revealjs-plugin
revealjs {
    version = "4.1.0" // ruby asciidoctor-revealjs backend
}

asciidoctorRevealJs {
    outputDir("$buildDir/docs")
    baseDirFollowsSourceDir()
    sourceDir("src/docs/asciidoc")
    sources {
        include("index.adoc")
    }
    attributes(
            "sourceDir": "src/docs/asciidoc",
            "imagesDir": "",
            "toc": "left",
            "icons": "font",
            "iconfont-name": "fontawesome-5.8.0",
            // Configurations not available via the `revealjsOptions` block
            // https://revealjs.com/config/
            "revealjs_controlsLayout": "edges", // Determines where controls appear, "edges" or "bottom-right"
            "revealjs_navigationMode": "linear" // Changes to linear navigation (left -right)
    )
    theme("blood") // https://revealjs.com/themes/
    revealjsOptions {
        setControls(true) // Display presentation control arrows
        setSlideNumber("c/t") // Display current over total slide number
        setOverviewMode(true) // Enable the slide overview mode https://revealjs.com/overview/
        setTransition("fade") // Slide transition style (none/fade/slide/convex/concave/zoom)
        setBackgroundTransition("convex") // Transition style for full page slide backgrounds
    }
}

asciidoctorj {
    version("2.5.2")
    fatalWarnings missingIncludes()
    modules {
        diagram.use()
        diagram.setVersion("2.2.1")
    }
}

build.dependsOn(asciidoctorRevealJs)
bric3 commented 2 years ago

It seems that asciidoctor-revealjs 4.1.0 is there in toquebox proxy, I believe that's what ruby.gems() declares.

$ curl http://rubygems-proxy.torquebox.org/releases/rubygems/asciidoctor-revealjs/4.1.0/
<!DOCTYPE html>
<html>
  <header>
    <title>gems/maven/releases/rubygems/asciidoctor-revealjs/4.1.0/</title>
  </header>
  <body>
    <h1>Index of gems/maven/releases/rubygems/asciidoctor-revealjs/4.1.0/</h1>
    <hr />
    <a href="..">../</a><br />
    <a href="asciidoctor-revealjs-4.1.0.gem">asciidoctor-revealjs-4.1.0.gem</a><br />
    <a href="asciidoctor-revealjs-4.1.0.gem.sha1">asciidoctor-revealjs-4.1.0.gem.sha1</a><br />
    <a href="asciidoctor-revealjs-4.1.0.pom">asciidoctor-revealjs-4.1.0.pom</a><br />
    <a href="asciidoctor-revealjs-4.1.0.pom.sha1">asciidoctor-revealjs-4.1.0.pom.sha1</a><br />
  <hr />
  </body>
</html>

The .gem file is actually a redirect (status 302) to rubygems.org.

bric3 commented 2 years ago

So I recreated a new project. Everything was fine, until the same loading error appeared, stopping the daemons, didn't help.

I noticed this message though just before the loading error started to surface.

$ ./gradlew asciidoctorRevealJs

BUILD SUCCESSFUL in 1s
2 actionable tasks: 2 up-to-date
Daemon will be stopped at the end of the build after running out of JVM memory
ghilainm commented 2 years ago

I have the same issue as you. The problem seems to be linked to the :asciidoctorGemsPrepare tasks. When I do:

./gradlew clean asciidoctorRevealJs --no-build-cache

It always works fine. So it seems to be a cache issue.

tkrah commented 2 years ago

Got the same problem but with the "asciidoctor-lists" gem when using the "asciidoctorPdf" task from the pdf plugin.

Exception in thread "main" org.jruby.exceptions.LoadError: (LoadError) no such file to load -- asciidoctor-lists
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:974)
        at uri_3a_classloader_3a_.META_minus_INF.jruby_dot_home.lib.ruby.stdlib.rubygems.core_ext.kernel_require.require(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54)
        at RUBY.<main>(<script>:1)

So it is some general problem, not related to revealjs itself.

build.gradle snippet:

plugins {
    id 'base'
    id 'org.asciidoctor.jvm.convert'
    id 'org.asciidoctor.jvm.pdf'
    id 'org.asciidoctor.jvm.gems'
}

repositories {
  ruby.gems()
  // https://github.com/jruby-gradle/jruby-gradle-plugin/issues/429
}
dependencies {
    asciidoctorGems 'rubygems:rouge:3.26.1'
    asciidoctorGems 'rubygems:asciidoctor-lists:1.0.7'
}

asciidoctorPdf {
    sourceDir = project(":docs").file("src/docs/toc")
    dependsOn asciidoctorGemsPrepare
    baseDirFollowsSourceDir()

    sources {
        include 'TOC_Example.adoc'
    }

    pdfThemes {
        local 'TOC', {
            themeDir = project(":docs").file("src/docs/themes")
            themeName = 'TOC'
        }
    }

    theme 'TOC'

    asciidoctorj {
        requires 'rouge'
        requires 'asciidoctor-lists'
        attributes = (pdfAttributes << [
                'description'                : 'Beschreibung')
    }

    inputs.dir(project(":docs").file("src/docs/toc"))
    inputs.dir(project(":docs").file("src/docs/themes"))
    outputs.dir("build/docs/asciidocPdf/")
    outputs.upToDateWhen { file("build/docs/asciidocPdf/TOC_Example.pdf").exists() }
}

Using --no-build-cache it always works, @bric3 maybe you can adjust the subject to some more general problem or should I open another ticket with basically the same problem, just another package name?

bric3 commented 2 years ago

@tkrah I will change the title. Thanks for reporting as well. That's good to have a work around.

diguage commented 1 year ago

I have the same issue as you. The problem seems to be linked to the :asciidoctorGemsPrepare tasks. When I do:

./gradlew clean asciidoctorRevealJs --no-build-cache

It always works fine. So it seems to be a cache issue.

The param works well. Thanks.

tkrah commented 8 months ago

@ysb33r - tried 4.0.1 and this still fails:


* What went wrong:
Execution failed for task ':KonfHb:asciidoctorPdf'.
> A failure occurred while executing org.ysb33r.grolifant.internal.v6.jvm.worker.InternalWorkerAppExecutor
   > org.jruby.exceptions.LoadError: (LoadError) no such file to load -- asciidoctor-lists

So imho this one is not fixed - even more worse, the workaround with "--no-build-cache" does not work anymore - so the whole build is broken now with anything greater than alpha1.

@bric3 can you reopen this one maybe?

last part of the stacktrace acquired with --stacktrace option:

Caused by: org.ysb33r.grolifant.api.remote.worker.WorkerExecutionException: org.jruby.exceptions.LoadError: (LoadError) no such file to load -- asciidoctor-lists
        at org.ysb33r.grolifant.internal.v6.jvm.worker.InternalWorkerAppExecutor.execute(InternalWorkerAppExecutor.groovy:39)
        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
        at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:54)
        at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:48)
        at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
        at org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:48)
        at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49)
        at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30)
        at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1.lambda$execute$0(IsolatedClassloaderWorkerFactory.java:57)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:78)
        at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
        at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1.execute(IsolatedClassloaderWorkerFactory.java:49)
        at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$0(DefaultWorkerExecutor.java:170)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:187)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:120)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:162)
        at org.gradle.internal.Factories$1.create(Factories.java:31)
        at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:264)
        at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:128)
        at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:133)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:157)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:126)
        ... 2 more
Caused by: org.jruby.exceptions.LoadError: (LoadError) no such file to load -- asciidoctor-lists
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1017)
        at uri_3a_classloader_3a_.META_minus_INF.jruby_dot_home.lib.ruby.stdlib.rubygems.core_ext.kernel_require.require(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85)
        at RUBY.<main>(<script>:1)
ysb33r commented 8 months ago

Is this specific to Build cache?

tkrah commented 8 months ago

I don't know the real underlying cause - we just discovered that using "-no-build-cache" was a working workaround running 3.x or 4.0.0-alpha1. With 4.0.1 that workaround does not work anymore and it does not matter if build-cache is enabled or not, it fails now with the LoadError in any case.

The files are at least prepared with the gemPrepare task in the build directory:

./KonfHb/build/.asciidoctorGems/cache/asciidoctor-lists-1.0.9.gem
./KonfHb/build/.asciidoctorGems/specifications/asciidoctor-lists-1.0.9.gemspec
./KonfHb/build/.asciidoctorGems/gems/asciidoctor-lists-1.0.9
./KonfHb/build/.asciidoctorGems/gems/asciidoctor-lists-1.0.9/lib
./KonfHb/build/.asciidoctorGems/gems/asciidoctor-lists-1.0.9/lib/asciidoctor-lists.rb
./KonfHb/build/.asciidoctorGems/gems/asciidoctor-lists-1.0.9/lib/asciidoctor-lists
./KonfHb/build/.asciidoctorGems/gems/asciidoctor-lists-1.0.9/lib/asciidoctor-lists/version.rb
./KonfHb/build/.asciidoctorGems/gems/asciidoctor-lists-1.0.9/lib/asciidoctor-lists/extensions.rb
./KonfHb/build/.asciidoctorGems/gems/asciidoctor-lists-1.0.9/README.adoc

I am not sure why jruby does fail to load them - maybe looking in the wrong place? There are no useful debug messages in the gradle debug output to give some better hints.

tkrah commented 8 months ago

@ysb33r I made some progress after digging through the code - with 4.0.1 it does build successfully if I change this in my build file:

+       withGemJar 'asciidoctorGemsJar'
        sourceDir = project(":docs").file("src/docs/KonfHb")
-       dependsOn asciidoctorGemsPrepare
+       dependsOn asciidoctorGemsPrepare, asciidoctorGemsJar

After that it is working just with a simple "gradle clean build" - nice. Sorry for the noise, but the latest docs from https://asciidoctor.github.io/asciidoctor-gradle-plugin/development-3.x/user-guide/ does not mention the withGemJar thingy and this ticket also did not mention it, but if I add it, it is working - is this expected? Do I have to add it to each of my asciidoctorPdf extensions or should this be done out-of-the-box from the plugin?

ysb33r commented 8 months ago

No problem. We are trying to get the documentation pipeline fixed.