-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Exception accessing file with long path on windows #3995
Comments
Example code and a sample directory structure, producing the error above. |
Thank you for the repro. A couple notes.
@enebo You worked on Windows stat stuff a few times...any ideas? |
Yes, JRuby and MRI crashed at the same directory depth. As mentioned above, I believe it is related to a legacy MAX_PATH definition of 260 characters in windows. Longer path names needs to be handled differently. This is full backtrace:
|
This is the corresponding MRI bug: https://bugs.ruby-lang.org/issues/12551 |
@lbenner Ahh, thanks for the extra info and the MRI bug link. We generally don't change functionality unilaterally, and I'm not sure how to fix this given that we're currently just using JDK features to navigate and manipulate paths. I'm inclined to see what ruby-core has to say about this one. If they come up with a solution (or you help us all come up with a solution) we'll see about getting it into JRuby. |
I am only a little bit surprised, because it was working with jruby 1.4.1 (ruby 1.8.7 patchlevel 174) (2010-04-26 6586) (Java HotSpot(TM) 64-Bit Server VM 1.8.0_60) [amd64-java], using the same JVM. But the same applies to the old MRI version. |
@lbenner This is pretty weird. I put a lot of effort in making long path support in the last 3-4 months. I even have a JUnit test for jnr-posix of a long path. I guess something is still not correct. MRI should also pass this. I am confused :) |
I think we should punt this until MRI decides how they want to handle it. |
No progress on MRI end. Detargeting. |
I tested this on Windows 11 (I have long paths enabled in OS) and could not reproduce this issue. Accessing long paths works on both MRI and JRuby. I have a project folder with a Code used for testing (ran with #!/usr/bin/env ruby
if __FILE__ == $PROGRAM_NAME
if ARGV.length < 1
puts "Only entered #{ARGV.length} arguments!"
puts "Usage: #{ARGV[0]} wildcard"
exit 1
end
require 'find'
wildcard = Regexp.new(ARGV[0]).freeze
Find.find('.') do |path|
if FileTest.file?(path)
if wildcard.match?(path)
puts path
end
end
end
end Ruby versions tested:
Example path printed: This issue should be closed. |
@headius, @enebo MRI handles long paths now on Windows. See this merged pull request. They enabled long path support via an application manifest which changes the behavior of Windows API calls (by removing MAX_PATH restrictions). Since long paths are working in JRuby this issue should be closed. |
I can still see this error when using File.chmod(0644, "C:/msys64/home/runneradmin/_bazel_runneradmin/r5xeuw7g/execroot/_main/bazel-out/x64_windows-fastbuild/bin/external/rules_ruby++ruby+bundle/vendor/bundle/jruby/3.1.0/gems/language_server-protocol-3.17.0.3/lib/language_server/protocol/interface/workspace_unchanged_document_diagnostic_report.rb")
org/jruby/RubyFile.java:650:in `chmod': No such process - No message available (Errno::ESRCH)
from (irb):3:in `evaluate'
from org/jruby/RubyKernel.java:1277:in `eval'
from org/jruby/RubyKernel.java:1725:in `loop'
from org/jruby/RubyKernel.java:1426:in `catch'
from org/jruby/RubyKernel.java:1426:in `catch'
from According to actions/runner-images#4913, the long paths are enabled. MRI also works fine on the same environment. Could there be anything specific for JRuby? |
Environment
Fails also with:
Works with:
Expected Behavior
The length of a file name respectively its path shall shall support more than 260 characters.
See https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath for more information.
Actual Behavior
When a script tries to access a file with a long path this exception is thrown:
C:/Projects/Head/Build/cm/testdir01/testdir02/testdir03/testdir04/testdir05/testdir06/testdir07/testdir08/testdir09/testdir10/testdir11/testdir12/testdir13/testdir14/testdir15/testdir16/testdir17/testdir18/testdir19/testdir20/testdir21/testdir22/longtestfile.name.txt
Errno::ESRCH: No such process - C:/Projects/Head/Build/cm/testdir01/testdir02/testdir03/testdir04/testdir05/testdir06/testdir07/testdir08/testdir09/testdir10/testdir11/testdir12/testdir13/testdir14/testdir15/testdir16/testdir17/testdir18/testdir19/testdir20/testdir21/testdir22/longtestfile.name.txt
stat at org/jruby/RubyFile.java:885
block in repro_lstat_exception.rb at repro_lstat_exception.rb:45
chdir at org/jruby/RubyDir.java:326
at repro_lstat_exception.rb:16
The text was updated successfully, but these errors were encountered: