Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to require GEMs #718

Open
markslater opened this issue Feb 26, 2024 · 11 comments
Open

Fails to require GEMs #718

markslater opened this issue Feb 26, 2024 · 11 comments

Comments

@markslater
Copy link

I'm having some difficulty requiring GEMs, using the example from the documentation.

Here's my build script:

buildscript {
    repositories {
        mavenCentral()
    }
}

plugins {
    id("org.asciidoctor.jvm.convert") version "4.0.2"
    id("org.asciidoctor.jvm.gems") version "4.0.2"
}

repositories {
    mavenCentral()
    ruby {
        gems()
    }
}

dependencies {
    asciidoctorGems("rubygems:asciidoctor-revealjs:1.1.3")
}

asciidoctorj {
    requires("asciidoctor-revealjs")
}

tasks {
    asciidoctor {
        dependsOn("asciidoctorGemsPrepare")
    }
}

And here's the output:

$ ./gradlew asciidoctor
Successfully installed thread_safe-0.3.6-java
Successfully installed asciidoctor-1.5.8
Successfully installed asciidoctor-revealjs-1.1.3
3 gems installed

> Task :asciidoctor
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:1017)
        at RUBY.require(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85)
        at RUBY.<main>(<script>:1)

> Task :asciidoctor FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':asciidoctor'.
> Process 'command '/usr/lib/jvm/java-11-openjdk-amd64/bin/java'' finished with non-zero exit value 1

* 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 14s
2 actionable tasks: 2 executed

I'm running:

$ ./gradlew --version

------------------------------------------------------------
Gradle 8.6
------------------------------------------------------------

Build time:   2024-02-02 16:47:16 UTC
Revision:     d55c486870a0dc6f6278f53d21381396d0741c6e

Kotlin:       1.9.20
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          11.0.21 (Ubuntu 11.0.21+9-post-Ubuntu-0ubuntu122.04)
OS:           Linux 5.15.0-97-generic amd64

I'm guessing there's some problem with the Ruby path configuration because I see:

$ ls build/.asciidoctorGems/gems/
asciidoctor-1.5.8  asciidoctor-revealjs-1.1.3  thread_safe-0.3.6-java

I'm very new to Asciidoctor, so apologies if I've missed something obvious. Full reproducer here

@abelsromero
Copy link
Member

v1.1.3 is an old version that is pulling another very old Asciidoctor, have tried the latest https://rubygems.org/gems/asciidoctor-revealjs/versions/5.1.0 ?

markslater added a commit to markslater/asciidoctor-examples that referenced this issue Feb 26, 2024
@markslater
Copy link
Author

You're right, @abelsromero , it's a long way out of date! Unfortunately, 5.1.0 produces the same result:

$ ./gradlew asciidoctor
Successfully installed asciidoctor-2.0.21
Successfully installed asciidoctor-revealjs-5.1.0
2 gems installed

> Task :asciidoctor
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:1017)
        at RUBY.require(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85)
        at RUBY.<main>(<script>:1)

> Task :asciidoctor FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':asciidoctor'.
> Process 'command '/usr/lib/jvm/java-11-openjdk-amd64/bin/java'' finished with non-zero exit value 1

* 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 35s
2 actionable tasks: 2 executed

@abelsromero
Copy link
Member

Sorry, forgot to come back. I could reproduce the issue in my machine (Linux) but could not deal with it currently. The current effort is in fixing docs, then we can address this.

@austinarbor
Copy link

Is there any workaround for this or is the only solution to wait for code fix?

@ysb33r
Copy link
Member

ysb33r commented Mar 12, 2024 via email

@markslater
Copy link
Author

Removing the requires line doesn't seem to work for me (certainly not for all GEMs at any rate; for example asciidoctor-tabs definitely doesn't work). I found a slightly grungy workaround though:

asciidoctorj {
    requires(
        project.layout.buildDirectory.file(".asciidoctorGems/gems/asciidoctor-revealjs-5.1.0/lib/asciidoctor-revealjs.rb")
    )
}

@austinarbor
Copy link

I was also trying with the asciidoctor-tabs extension but couldn't get it to work

@mojavelinux
Copy link
Member

It's pretty important to be able to add additional gems. Is the problem with this plugin, or in the JRuby plugin? I don't think we want to see a proliferation of builds that are relying on internal behavior, so it seems to be something worth figuring out.

@markslater
Copy link
Author

While I fully agree with @mojavelinux that the proliferation of a workaround is undesirable, in the interests of expediency, @austinarbor asciidoctor-tabs works for me with this:

asciidoctorj {
    requires(
        "asciidoctor",
        project.layout.buildDirectory.file(".asciidoctorGems/gems/asciidoctor-tabs-1.0.0.beta.6/lib/asciidoctor-tabs.rb")
    )
}

See here for an example project.

@austinarbor
Copy link

@markslater thanks! can confirm this works on Gradle 8.6, but does not appear to work on Gradle 8.7

exception thrown for request to /rubygems/asciidoctor-tabs/1.0.0.beta.6/ivy.xml
java.lang.NoClassDefFoundError: org/gradle/wrapper/ExclusiveFileAccessManager
        at java.base/java.lang.Class.getDeclaredFields0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3297)
        at java.base/java.lang.Class.getDeclaredFields(Class.java:2371)
        at org.codehaus.groovy.reflection.CachedClass$1.lambda$initValue$2(CachedClass.java:59)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
        at org.codehaus.groovy.reflection.CachedClass$1.initValue(CachedClass.java:62)
        at org.codehaus.groovy.reflection.CachedClass$1.initValue(CachedClass.java:54)
        at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:50)
        at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:37)
        at org.codehaus.groovy.reflection.CachedClass.getFields(CachedClass.java:256)
        at groovy.lang.MetaClassImpl.addFields(MetaClassImpl.java:2499)
        at groovy.lang.MetaClassImpl.inheritFields(MetaClassImpl.java:2494)
        at groovy.lang.MetaClassImpl.setupProperties(MetaClassImpl.java:2380)
        at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3421)
        at groovy.lang.MetaClassImpl.reinitialize(MetaClassImpl.java:3395)
        at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3388)
        at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:273)
        at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:315)
        at org.ysb33r.grolifant.api.core.ExclusiveFileAccess.$getStaticMetaClass(ExclusiveFileAccess.groovy)
        at org.ysb33r.grolifant.api.core.ExclusiveFileAccess.<init>(ExclusiveFileAccess.groovy)
        at org.ysb33r.gradle.jruby.internal.core.DefaultIvyXmlFactory.createIvyXml(DefaultIvyXmlFactory.groovy:152)
        at org.ysb33r.gradle.jruby.internal.core.DefaultIvyXmlFactory.ivyXmlPath(DefaultIvyXmlFactory.groovy:87)
        at org.ysb33r.gradle.jruby.internal.resolver.RatpackServerFactory.lambda$null$0(RatpackServerFactory.java:63)
        at ratpack.handling.internal.DefaultContext.next(DefaultContext.java:157)
        at ratpack.handling.internal.MethodHandler.handle(MethodHandler.java:44)
        at ratpack.handling.internal.DefaultContext.next(DefaultContext.java:157)
        at ratpack.handling.internal.DefaultContext.insert(DefaultContext.java:179)
        at ratpack.path.internal.PathHandler.handle(PathHandler.java:61)
        at ratpack.handling.internal.DefaultContext.next(DefaultContext.java:157)
        at ratpack.handling.internal.DefaultContext.lambda$start$4(DefaultContext.java:104)
        at ratpack.exec.internal.DefaultExecution.lambda$new$0(DefaultExecution.java:82)
        at ratpack.exec.internal.DefaultExecution$InitialExecStream.exec(DefaultExecution.java:403)
        at ratpack.exec.internal.DefaultExecution.exec(DefaultExecution.java:224)
        at ratpack.exec.internal.DefaultExecution.exec(DefaultExecution.java:217)
        at ratpack.exec.internal.DefaultExecution.drain(DefaultExecution.java:187)
        at io.netty.util.concurrent.PromiseTask$RunnableAdapter.call(PromiseTask.java:38)
        at io.netty.util.concurrent.PromiseTask.run(PromiseTask.java:73)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:474)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
        at ratpack.exec.internal.DefaultExecController$ExecControllerBindingThreadFactory.lambda$newThread$0(DefaultExecController.java:137)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.ExclusiveFileAccessManager
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader.findClass(VisitableURLClassLoader.java:187)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        ... 44 more

@markslater
Copy link
Author

@austinarbor see #725

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants