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

(SystemCallError) Unknown error 123 - FindFirstFile with AsciidoctorJ on Win10 #3957

Closed
robertpanzer opened this issue Jun 7, 2016 · 18 comments
Labels
Milestone

Comments

@robertpanzer
Copy link

Environment

Win 10, Java 1.8.0_65, JRuby 9.1.2.0
AsciidoctorJ 1.6.0-alpha.3 i.e. no gems installed but packaged in jars like:
Asciidoctor 1.5.5
Prawn 1.3.0

Expected Behavior

When trying to render this document AsciidoctorJ should produce a PDF document and it does on OSX.

Actual Behavior

Create this document named test.adoc:

= Test document

Test

Download AsciidoctorJ 1.6.0-alpha.3 from http://jcenter.bintray.com/org/asciidoctor/asciidoctorj/1.6.0-alpha.3/:asciidoctorj-1.6.0-alpha.3-bin.zip, unpack it and invoke asciidoctorj -b pdf ..../test.adoc.

On Win10 this fails with this exception:

c:\Temp\asciidoctorj-1.6.0-alpha.3\bin>asciidoctorj -b pdf c:\temp\test.adoc
Exception in thread "main" org.jruby.exceptions.RaiseException: (SystemCallError) Unknown error 123 - FindFirstFile
        at RUBY.symlink?(uri:classloader:/jruby/kernel/file.rb:127)
        at RUBY.<module:Prawn>(uri:classloader:/gems/prawn-1.3.0/lib/prawn.rb:15)
        at RUBY.<top>(uri:classloader:/gems/prawn-1.3.0/lib/prawn.rb:11)
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:944)
        at RUBY.(root)(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1)
        at RUBY.<top>(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55)
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:944)
        at RUBY.(root)(uri:classloader:/gems/asciidoctor-pdf-1.5.0.alpha.11/lib/asciidoctor-pdf/converter.rb:3)
        at RUBY.(root)(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1)
        at RUBY.<top>(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55)
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:944)
        at RUBY.require_relative(uri:classloader:/jruby/kernel/kernel.rb:13)
        at RUBY.<top>(uri:classloader:/gems/asciidoctor-pdf-1.5.0.alpha.11/lib/asciidoctor-pdf.rb:3)

Side note: I actually wanted to report an error that the build of AsciidoctorJ does not pass on Win10 because the source highlighter rouge cannot be found. Therefore I wanted to see if I also have this problem with the packaged version of AsciidoctorJ, but it turns out I don't even get that far.

@idc101
Copy link

idc101 commented Jun 30, 2016

I see the same problem on Win7 with:

  • org.jruby.jruby-complete:9.1.2.0
  • org.asciidoctor:asciidoctorj:1.6.0-alpha.3
  • org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.11
  • Java 1.8.0_92

Note: JRuby-complete rather than JRuby. Using JRuby I don't get this far and get a different error:

Caught: org.jruby.exceptions.RaiseException: (LoadError) Could not load FFI Provider: (NotImplementedError) FFI not available: com/kenai/jffi/Platform

@enebo enebo added this to the JRuby 9.1.3.0 milestone Jul 1, 2016
@enebo enebo added the windows label Jul 1, 2016
@enebo
Copy link
Member

enebo commented Jul 1, 2016

@robertpanzer I guess 123 is an invalid name error on windows: http://forums.codeguru.com/showthread.php?116333-FindFirstFile-fails-for-wildcard-characters-in-the-path

The file it is tripping on is our symlink? checking code (which is required for newer version of rubygems). If you can provide some reproduction I can try it locally and track down the file. If you want to try and narrow down the file it is tripping on you can add a puts to gems/prawn-1.3.0/lib/prawn.rb before line 15 and see what it is calling symlink on.

@idc101 your problem is completely unrelated to this one. You can open a new issue for it. It sort of looks like an environment issue since it is saying you cannot load FFI (which is how we call native methods below Java/Ruby).

@robertpanzer
Copy link
Author

@enebo I added a puts "FILE #{file}" just before the line that fails to prawn.rb.
I get this result:

FILE uri:classloader:/gems/prawn-1.3.0/lib/prawn.rb
Exception in thread "main" org.jruby.exceptions.RaiseException: (SystemCallError) Unknown error 123 - FindFirstFile
        at RUBY.symlink?(uri:classloader:/jruby/kernel/file.rb:127)
        at RUBY.<module:Prawn>(uri:classloader:/gems/prawn-1.3.0/lib/prawn.rb:16)
        at RUBY.<top>(uri:classloader:/gems/prawn-1.3.0/lib/prawn.rb:11)
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:944)
        at RUBY.(root)(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1)
        at RUBY.<top>(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:68)
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:944)
        at RUBY.(root)(uri:classloader:/gems/asciidoctor-pdf-1.5.0.alpha.11/lib/asciidoctor-pdf/converter.rb:3)
        at RUBY.(root)(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1)
        at RUBY.<top>(uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:120)
        at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:944)
        at RUBY.require_relative(uri:classloader:/jruby/kernel/kernel.rb:13)
        at RUBY.<top>(uri:classloader:/gems/asciidoctor-pdf-1.5.0.alpha.11/lib/asciidoctor-pdf.rb:3)

Please note that all gems are installed and then packaged into jars during the build of AsciidoctorJ.

If you want to reproduce you can download the distribution of AsciidoctorJ (had the link already in the issue description above), create a file test.adoc with this content:

= Test

Test

and then invoke asciidoctorj -b pdf test.adoc.

@idc101
Copy link

idc101 commented Jul 4, 2016

As a workaround just commenting out the symlink call works in prawn.rb line 15:

# file = File.readlink(file) if File.symlink?(file)

@headius
Copy link
Member

headius commented Jul 11, 2016

Ok, looks like we need to short-circuit logic for File.symlink when it looks like we're dealing with a non-file URL. @mkristian @kares Do we have a central place for logic like that?

@headius
Copy link
Member

headius commented Aug 15, 2016

This is a possible patch. I don't have Windows handy to test at the moment.

diff --git a/core/src/main/ruby/jruby/kernel/file.rb b/core/src/main/ruby/jruby/kernel/file.rb
index 4b58a6e..3a93a2d 100644
--- a/core/src/main/ruby/jruby/kernel/file.rb
+++ b/core/src/main/ruby/jruby/kernel/file.rb
@@ -118,7 +118,12 @@ if org.jruby.platform.Platform::IS_WINDOWS
         return false unless File.exist?(file)

         bool  = false
-        wfile = string_check(file).wincode
+        checked = string_check(file)
+        
+        return false if checked =~ /^(classpath:)|(classloader:)|(uri:classloader)|(jar:)/
+        checked.slice!(5..-1) if checked =~ /^file:/
+
+        wfile = checked.wincode

         attrib = GetFileAttributesW(wfile)

I believe this is caused by having prawn bundled into the JRuby app and run from the classloader. It attempts to determine if one of its own files is a symlink, which blow sup when trying to test classloader resources. This patch short-circuits all in-jar URL forms as always being "false" and strips off any file: protocol for other cases.

@headius
Copy link
Member

headius commented Aug 22, 2016

@idc101 We are pushing 9.1.3.0 out very soon. If you can verify this patch works for you, we'd be willing to incorporate it into the release. Otherwise this will get bumped to 9.1.4.0.

@idc101
Copy link

idc101 commented Aug 22, 2016

Sure, what's the best way for me to test the patch?

On Tuesday, 23 August 2016, Charles Oliver Nutter <notifications@github.com
javascript:_e(%7B%7D,'cvml','notifications@github.com');> wrote:

@idc101 https://github.com/idc101 We are pushing 9.1.3.0 out very soon.
If you can verify this patch works for you, we'd be willing to incorporate
it into the release. Otherwise this will get bumped to 9.1.4.0.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#3957 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AG2xuD5D_DgQnOJZVWZA4H-vkd3JDLTXks5qihIGgaJpZM4Iv8l9
.

@headius
Copy link
Member

headius commented Aug 22, 2016

@idc101 Hopefully you can build JRuby...if not, have a look at BUILDING; it's pretty easy.

Throw that patch above on your local copy and go for it. If it works, it works!

@robertpanzer
Copy link
Author

Just retested building asciidoctorj-1.6.0 with a jruby 9.1.3.0-SNAPSHOT and it seems to work indeed! \o/

@headius
Copy link
Member

headius commented Aug 23, 2016

@robertpanzer Without any additional patching? Or with the patch I pasted above?

@robertpanzer
Copy link
Author

Yes, without patching, totally forgot that and this test ran successfully. :)
Retried again this morning first with 9.1.2.0 which failed and then with 9.1.3.0-SNAPSHOT (88b3022) which succeeded.

Having two other issues though, for which I will file new tickets:

@enebo
Copy link
Member

enebo commented Aug 24, 2016

@robertpanzer If they are simple and you get them in extremely soon we might get the new ones for 9.1.3.0 but we need a release out soon. So the quicker you can report them the better.

@enebo enebo closed this as completed Aug 24, 2016
@robertpanzer
Copy link
Author

@enebo Filed #4114

@dzwicker
Copy link

using 9.1.12.0 i hit this bug. using 9.1.3.0 fixed it. Is there a regression?

@enebo
Copy link
Member

enebo commented Aug 15, 2017

@dzwicker can you open up a new issue and paste in the stack trace you see. We have 2 in this issue and I would like to capture this as a regression issue (assuming it is and not something else throwing the same error perhaps we missed?). I do know there is another issue involving classpath: paths, but more info the better.

@robertpanzer
Copy link
Author

Just want to add that I downgraded to 9.1.8.0 for the AsciidoctorJ distribution as I also experienced this problem with 9.1.12.0 on Win10.
So 9.1.8.0 should be fine as well.

@enebo
Copy link
Member

enebo commented Aug 15, 2017

I am wondering if #4543 caused this regression since it broke some other stuff on windows.

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

No branches or pull requests

5 participants