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

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

Closed
mkristian opened this issue May 22, 2015 · 7 comments

Comments

@mkristian
Copy link
Member

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
@mkristian mkristian self-assigned this May 22, 2015
@deepj
Copy link

deepj commented May 22, 2015

This issue is causing failing some tests in Lotus::Model -> https://travis-ci.org/lotus/model/jobs/63672086

It fails on the following uri file:////home/dev/lotus/model/tmp/db/filesystem.

@mkristian
Copy link
Member Author

@deepj I am bit surprised to see the file:// protocol since jruby-9k kind of uri:classloader:// internally. but of course your should work as well and it fits this issue ;)

@deepj
Copy link

deepj commented May 23, 2015

:)

@deepj
Copy link

deepj commented May 28, 2015

Hm :) Any news about this? This blocks me a bit from moving far in investigation what yet doesn't work with Lotus and JRuby 9k. I mean my case mainly :)

@mkristian
Copy link
Member Author

mkristian commented May 28, 2015 via email

@deepj
Copy link

deepj commented May 28, 2015

👍 Thanks!

mkristian added a commit that referenced this issue May 29, 2015
* there was a problem with file:////path/to/dir where the extra slashes
  did confuse the logic
* all pathes starting with uri: can not create any directories

fixes #2972

Sponsored by Lookout Inc.
@mkristian
Copy link
Member Author

@deepj pushed it to jruby-1_7 once this is green I merge it to master and close issue

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

3 participants