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

File.symlink? fails on Windows, in 9.1.2.0 #3953

Closed
mnepveu opened this issue Jun 6, 2016 · 15 comments
Closed

File.symlink? fails on Windows, in 9.1.2.0 #3953

mnepveu opened this issue Jun 6, 2016 · 15 comments

Comments

@mnepveu
Copy link

mnepveu commented Jun 6, 2016

Calling File.symlink? throws an exception on jruby 9.1.2.0, on Windows.

Environment:
jruby 9.1.2.0 (complete jar)
Windows 10
Java SE 1.8 u 91
Prawn 2.1

Code from Prawn:
file = File.readlink(file) if File.symlink?(file)

Exception in thread "AWT-EventQueue-0" org.jruby.exceptions.RaiseException: (ESRCH) No such process - FindFirstFile
    at RUBY.symlink?(uri:classloader:/jruby/kernel/file.rb:127)
    at RUBY.<module:Prawn>(uri:classloader:/gems/prawn-2.1.0/lib/prawn.rb:15)
    at RUBY.<top>(uri:classloader:/gems/prawn-2.1.0/lib/prawn.rb:11)
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:944)
    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:133)
...
@djberg96
Copy link
Contributor

djberg96 commented Jun 7, 2016

@headius @enebo Did you also borrow the custom File.readlink method from win32-file? If not, you'll need that.

The one difference on Windows is that it will fail on a stale link. Also, GetFinalPathnameByHandle requires Vista or later.

@djberg96
Copy link
Contributor

djberg96 commented Jun 7, 2016

Also, you may need to update File.realpath and File.realdirpath the way I did.

If you do, I recommend validating this against the rubygems test suite at each step, however, as somehow win32-file breaks it. I'm not sure it's those methods in particular (I suspect it's basename/dirname), but you'll want to ensure these custom methods don't break anything there in particular.

@nirvdrum
Copy link
Contributor

nirvdrum commented Jun 7, 2016

@djberg96 Not to derail the conversation, but is the Artistic 2.0 license compatible with JRuby's? I'd love to pull some of your stuff into jnr-posix, which I think would help Win32 compatibility more widely, but I don't want to fall on the wrong side of licensing.

@djberg96
Copy link
Contributor

djberg96 commented Jun 8, 2016

@nirvdrum As far as I know it's compatible. I'm probably going to switch everything over to Apache 2.0 soon.

@hathawad
Copy link

I get a similar error when trying to boot a Rails 4.0 app w/ Bundler and Apache Tomcat 8

Environment:
jruby 9.1.2.0 (complete jar w/ warbler)
Windows Server 2008
Java SE 1.8 u 91
Rails 4.0
Bundler 1.11.2

No such process - FindFirstFile from uri:classloader:/jruby/kernel/file.rb:127:in `symlink?' from /C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/lib/jruby-stdlib-9.1.2.0.jar!/META-INF/jruby.home/lib/ruby/stdlib/rubygems/specification.rb:2681:in `block in validate' from org/jruby/RubyArray.java:2620:in `delete_if' from /C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/lib/jruby-stdlib-9.1.2.0.jar!/META-INF/jruby.home/lib/ruby/stdlib/rubygems/specification.rb:2681:in `validate' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/rubygems_integration.rb:51:in `block in validate' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/ui/silent.rb:40:in `silence' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/rubygems_integration.rb:51:in `validate' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler.rb:346:in `block in load_gemspec_uncached' from org/jruby/RubyDir.java:323:in `chdir' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/shared_helpers.rb:53:in `block in chdir' from /C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/lib/jruby-stdlib-9.1.2.0.jar!/META-INF/jruby.home/lib/ruby/stdlib/monitor.rb:214:in `mon_synchronize' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/shared_helpers.rb:52:in `chdir' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler.rb:339:in `load_gemspec_uncached' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler.rb:329:in `load_gemspec' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/source/path.rb:135:in `block in load_spec_files' from org/jruby/RubyArray.java:1593:in `each' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/source/path.rb:134:in `load_spec_files' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/source/path.rb:92:in `local_specs' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/source/path.rb:100:in `specs' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/definition.rb:435:in `specs_changed?' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/definition.rb:467:in `block in converge_paths' from org/jruby/RubyArray.java:4093:in `any?' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/definition.rb:466:in `converge_paths' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/definition.rb:90:in `initialize' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/dsl.rb:173:in `to_definition' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/dsl.rb:11:in `evaluate' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/definition.rb:24:in `build' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler.rb:120:in `definition' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler.rb:88:in `setup' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/gems/gems/bundler-1.11.2/lib/bundler/setup.rb:18:in `' from org/jruby/RubyKernel.java:944:in `require' from /C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/lib/jruby-stdlib-9.1.2.0.jar!/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `(root)' from /C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/lib/jruby-stdlib-9.1.2.0.jar!/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:133:in `' from org/jruby/RubyKernel.java:944:in `require' from C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/config/boot.rb:6:in `(root)' from /C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/lib/jruby-stdlib-9.1.2.0.jar!/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `(root)' from /C:/Program Files/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/lib/jruby-stdlib-9.1.2.0.jar!/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55:in `require' from uri:classloader:/jruby/rack/rails/environment3.rb:23:in `'

@gerhardgruber
Copy link
Contributor

👍

I just reproduced it on my machine:
jruby 9.1.13.0 (complete jar w/ warbler)
Windows Server 2012 R2
Java SE 1.8.0_144
Rails 4.1.7.1
Bundler 1.13.6

No such process - FindFirstFile from uri:classloader:/jruby/kernel/file.rb:146:in `symlink?' from uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/specification.rb:2722
...

@gerhardgruber
Copy link
Contributor

gerhardgruber commented Sep 20, 2017

Would it be possible to use isSymbolicLink (https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#isSymbolicLink-java.nio.file.Path-) to check if the file is a symbolic link in this method (

def self.symlink?(file)
)?

@kares
Copy link
Member

kares commented Sep 20, 2017

yep for 9.2 (master) definitely ... although some of the logic needs to stay - feel free to open up a PR

@kares kares added this to the JRuby 9.2.0.0 milestone Sep 20, 2017
@gerhardgruber
Copy link
Contributor

Ok. Trank you! I‘ll give it a try :)

@headius
Copy link
Member

headius commented Nov 10, 2017

@gerhardgruber Have any trouble making that PR? Can we help?

gerhardgruber added a commit to documatrix/jruby that referenced this issue Nov 10, 2017
@gerhardgruber
Copy link
Contributor

@headius Actually I had some troubles building JRuby on my machine, but now it worked. I opened a PR. As it is my first contribution to JRuby I hope I did all right 😉

@headius
Copy link
Member

headius commented Nov 12, 2017

@gerhardgruber Looks good to me! I've wanted to start using Java 7 NIO.2 APIs to replace some of our logic, so this is great! Feel free to replace other things that we know work properly with NIO.2!

@headius
Copy link
Member

headius commented Nov 12, 2017

Fixed by #4852. Thanks!

@headius headius closed this as completed Nov 12, 2017
@kares
Copy link
Member

kares commented Nov 12, 2017

@headius these are Java 8 specific APIs - which is fine for 9.2 but not for 9.1 (won't work on Java 7)

@kares
Copy link
Member

kares commented Nov 12, 2017

sorry - false alarm isSymbolicLink is Java 7 ... somehow thought it wasn't available till Java 8

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

No branches or pull requests

7 participants