Dir.new does not work for directories inside jar file -----------------------------------------------------
Key: JRUBY-3478 URL: http://jira.codehaus.org/browse/JRUBY-3478 Project: JRuby Issue Type: Bug Components: Core Classes/Modules Affects Versions: JRuby 1.1.6, JRuby 1.2 Environment: JRuby 1.1.6 and JRuby 1.2.0RC2, Java 1.6.0_11, Linux 2.6.27-13-generic #1 SMP x86_64 GNU/Linux Reporter: Manfred Usselmann Dir.new fails with 'Errno::ENOENT - No such file or directory - 'path' is not a directory' if path denotes a directory inside a jar file. Example: dir = File.expand_path(File.dirname(__FILE__)) + '/database/migrations/' puts "#{Dir.new(dir).inspect}" ==> Error in application Errno::ENOENT - No such file or directory - file:/home/manfred/projects/my_app/package/jar/my_app.jar!/database/migrations/ is not a directory This also happens if I remove 'file:': puts "#{Dir.new(dir.gsub('file:', '')).inspect}" ==> Error in application Errno::ENOENT - No such file or directory - /home/manfred/projects/my_app/package/jar/my_app.jar!/database/migrations/ is not a directory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - I noticed that problem while using Sequel migrations: When I run my app via the jar file sequel migrations fail while searching for migration classes inside the given directory: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Errno::ENOENT - No such file or directory - file:/[...]/my_app.jar!/database/migrations/ is not a directory lib/ruby/sequel-2.11.0/lib/sequel_core/migration.rb:192:in `migration_files' lib/ruby/sequel-2.11.0/lib/sequel_core/migration.rb:181:in `migration_classes' src/main.rb:91:in `require' Line 181: migration_files(directory, range).each {|fn| load(fn)} Line 192: Dir.new(directory).each do |file| files[file.to_i] = File.join(directory, file) if MIGRATION_FILE_PATTERN.match(file) end - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This issue may be related to http://jira.codehaus.org/browse/JRUBY-2289 "File.directory? returns false for directories inside a jar" dir = File.expand_path(File.dirname(__FILE__)) + '/database/migrations/' puts "dir: #{dir} directory? #{File.directory? dir}" ==> "dir: file:/home/manfred/projects/my_app/package/jar/my_app.jar!/database/migrations/ directory? false" puts "dir: #{dir.gsub('file:', '')} directory? #{File.directory? dir.gsub('file:', '')}" ==> "dir: /home/manfred/projects/my_app/package/jar/my_app.jar!/database/migrations/ directory? false" -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email