Bug #3594

URI class doesn't do file URL's properly.

Added by NeilW (Neil Wilson) over 8 years ago. Updated 12 months ago.

Target version:
ruby -v:
ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]


URI doesn't seem to output file URLs properly where there is an absolute path part.

For example.

require 'uri'

my_url = URI.parse("file:///var/lib/libvirt/images/")
p my_url.to_s


The double slash '//' should always appear according to the file URL specification.


#1 Updated by akr (Akira Tanaka) over 7 years ago

  • Project changed from Ruby to Ruby trunk
  • Assignee set to akira (akira yamada)

#2 Updated by shyouhei (Shyouhei Urabe) over 6 years ago

  • Status changed from Open to Assigned

#3 [ruby-core:50719] Updated by mame (Yusuke Endoh) almost 6 years ago

  • Description updated (diff)

Is this specified in RFC or any spec?

Yusuke Endoh

#4 [ruby-core:50722] Updated by naruse (Yui NARUSE) almost 6 years ago

mame (Yusuke Endoh) wrote:

Is this specified in RFC or any spec?

There's no available RFC of file URI scheme.

see also:

#5 [ruby-core:83918] Updated by mame (Yusuke Endoh) 12 months ago

RFC 8089 (The "file" URI Scheme) has been published in 2017. It says:

      file-URI       = file-scheme ":" file-hier-part

      file-scheme    = "file"

      file-hier-part = ( "//" auth-path )
                     / local-path

      auth-path      = [ file-auth ] path-absolute

      local-path     = path-absolute

and RFC 3986 says:

      path-absolute = "/" [ segment-nz *( "/" segment ) ]

So, "file:/var/lib/libvirt/images/" does not conform the spec, I think.

The maintainer of lib/uri.rb is Akira Yamada, who seems inactive. Does anyone want to investigate and fix this issue?

#6 [ruby-core:83933] Updated by mame (Yusuke Endoh) 12 months ago

  • Status changed from Assigned to Rejected

Sorry, I misread the spec. The URI is valid because it can be interpreted as file-scheme ":" local-path. So, there is no problem. Closing.

#7 [ruby-core:84029] Updated by naruse (Yui NARUSE) 12 months ago

  • Status changed from Rejected to Closed

I found the description in URL spec.
Therefore I fixed it at r60970.

Also available in: Atom PDF