Skip to content

creating a directory via uri-like path 'uri:classloader://new_dir' acts wrongly  #2972

@mkristian

Description

@mkristian

a classloader or classpath is not associated to single "path" and might not even have any path on filesystem.

just a few examples:

$ bin/jruby -rfileutils -e 'p FileUtils.mkdir "uri:classloader://new_dir"'
Errno::ENOENT: No such file or directory - /home/christian/projects/active/jruby/jruby/uri:classloader:/new_dir
     mkdir at org/jruby/RubyDir.java:460
  fu_mkdir at /home/christian/projects/active/jruby/jruby/lib/ruby/1.9/fileutils.rb:247
     mkdir at /home/christian/projects/active/jruby/jruby/lib/ruby/1.9/fileutils.rb:176
      each at org/jruby/RubyArray.java:1613
     mkdir at /home/christian/projects/active/jruby/jruby/lib/ruby/1.9/fileutils.rb:175
    (root) at -e:1

same with Dir

$ bin/jruby -e 'p Dir.mkdir "uri:classloader://new_dir"'
Errno::ENOENT: No such file or directory - /home/christian/projects/active/jruby/jruby/uri:classloader:/new_dir
   mkdir at org/jruby/RubyDir.java:460
  (root) at -e:1

and with mkdir_p things are different:

$ bin/jruby -rfileutils -e 'p FileUtils.mkdir_p "uri:classloader://new_dir"'
["uri:classloader://new_dir"]

which just creates a something on the filesystem.

using the runnable.jar from this integration test

mvn -Pmain -Dinvoker.test=runnable

behaves slightly different:

$ java -jar maven/jruby/target/it/runnable/runnable.jar -rfileutils -e 'p FileUtils.mkdir "uri:classloader://new_dir"'
JRubyFile.java:127:in `createNoUnicodeConversion': java.lang.IllegalArgumentException: Neither current working directory (uri:classloader://) nor pathname (uri:classloader://new_dir) led to an absolute path
    from JRubyFile.java:59:in `create'
    from RubyDir.java:673:in `getDir'
    from RubyDir.java:461:in `mkdirCommon'
    from RubyDir.java:457:in `mkdir19'
    from RubyDir$INVOKER$s$0$1$mkdir19.gen:-1:in `call'
    from JavaMethod.java:680:in `call'
    from DynamicMethod.java:205:in `call'
    from CachingCallSite.java:313:in `cacheAndCall'
    from CachingCallSite.java:163:in `call'
    from InterpreterEngine.java:292:in `processCall'
    from StartupInterpreterEngine.java:78:in `interpret'
    from MixedModeIRMethod.java:133:in `INTERPRET_METHOD'
    from MixedModeIRMethod.java:119:in `call'
    from WrapperMethod.java:91:in `call'
    from CachingCallSite.java:273:in `cacheAndCall'
    from CachingCallSite.java:79:in `callBlock'
    from CachingCallSite.java:83:in `call'
    from CallBase.java:419:in `interpret'
    from InterpreterEngine.java:324:in `processCall'
    from StartupInterpreterEngine.java:78:in `interpret'
    from Interpreter.java:137:in `INTERPRET_BLOCK'
    from InterpretedIRBlockBody.java:114:in `commonYieldPath'
    from IRBlockBody.java:137:in `doYield'
    from BlockBody.java:77:in `yield'
    from Block.java:147:in `yield'
    from RubyArray.java:1571:in `each'
    from RubyArray$INVOKER$i$0$0$each.gen:-1:in `call'
    from JavaMethod.java:473:in `call'
    from CachingCallSite.java:273:in `cacheAndCall'
    from CachingCallSite.java:79:in `callBlock'
    from CachingCallSite.java:83:in `call'
    from CallBase.java:419:in `interpret'
    from InterpreterEngine.java:324:in `processCall'
    from StartupInterpreterEngine.java:78:in `interpret'
    from InterpreterEngine.java:84:in `interpret'
    from MixedModeIRMethod.java:203:in `INTERPRET_METHOD'
    from MixedModeIRMethod.java:189:in `call'
    from DynamicMethod.java:205:in `call'
    from WrapperMethod.java:59:in `call'
    from CachingCallSite.java:313:in `cacheAndCall'
    from CachingCallSite.java:163:in `call'
    from -e:-1:in `invokeOther1:mkdir'
    from -e:1:in `RUBY$script'
    from MethodHandle.java:625:in `invokeWithArguments'
    from Compiler.java:111:in `load'
    from Ruby.java:833:in `runScript'
    from Ruby.java:822:in `runScript'
    from Ruby.java:752:in `runNormally'
    from Ruby.java:574:in `runFromMain'
    from Main.java:401:in `doRunFromMain'
    from Main.java:296:in `internalRun'
    from Main.java:225:in `run'
    from JRubyMain.java:75:in `run'
    from JRubyMain.java:19:in `main'
    from JarMain.java:6:in `main'

some exception with Dir.mkdir or FileUtils.mkdir

all this happens even if

$ bin/jruby -e 'p File.directory? "uri:classloader://new_dir"'
true

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions