Project

General

Profile

Actions

Bug #8525

closed

Error? in pathname :: Pathname.new(`pwd`.chomp).basename.realpath

Added by dimytch (Dimitri Peka) almost 11 years ago. Updated almost 11 years ago.

Status:
Rejected
Assignee:
-
Target version:
ruby -v:
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux]
[ruby-core:55483]

Description

[code]
Dir.chdir '/tmp'
p = Pathname.new(pwd.chomp).basename.realpath
Errno::ENOENT: No such file or directory - /tmp/tmp
from (irb):17:in realpath' from (irb):17:in realpath'
from (irb):17
from /usr/bin/irb:12:in `'
[/code]

As I got p must be '/tmp'. Am I wrong?

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

  • Status changed from Open to Rejected

Pathname.new("/tmp").basename returns "tmp", and expanded result from "/tmp" is "/tmp/tmp".
If you want pathname which may not exist, use Pathname#realdirpath instead.

Actions

Also available in: Atom PDF

Like0
Like0