File.expand_path should fail if ENV['HOME'] isn't an absolute path #1163

Closed
nirvdrum opened this Issue Oct 24, 2013 · 1 comment

Projects

None yet

2 participants

@nirvdrum
Contributor

I ran into a corner case with File.expand_path that's causing a test failure with fog. I guess if ENV['HOME'] isn't an absolute path, MRI will fail to expand a path containing '~'.

$ ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

irb(main):001:0> ENV['HOME'] = '.'
=> "."
irb(main):002:0> File.expand_path('~/.fog')
ArgumentError: non-absolute home
    from (irb):3:in `expand_path'
    from (irb):3
    from /home/nirvdrum/.rbenv/versions/2.0.0-p247/bin/irb:12:in `<main>'
$ ruby --version
jruby 1.7.6 (1.9.3p392) 2013-10-22 6004147 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_45-b18 [linux-amd64]

irb(main):001:0> ENV['HOME'] = '.'
=> "."
irb(main):002:0> File.expand_path('~/.fog')
=> "/home/nirvdrum/dev/workspaces/fog/.fog
@enebo enebo added a commit that referenced this issue Oct 24, 2013
@enebo enebo Merge fix for #1163 f1b5dbc
@enebo enebo closed this in f72b75b Oct 24, 2013
@enebo
Member
enebo commented Oct 24, 2013

Very simple missing checks but this code gets uglier and uglier...a nice 9k cleanup refactoring of expand_path code for someone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment