Opened 8 years ago

Last modified 2 years ago

#40035 new defect

base aborts if current directory does not exist, even when given a port name

Reported by: larryv (Lawrence Velázquez) Owned by: larryv (Lawrence Velázquez)
Priority: Low Milestone:
Component: base Version: 2.2.0
Keywords: Cc: cooljeanius (Eric Gallager), Ionic (Mihai Moldovan), chrstphrchvz (Christopher Chavez)


Sorry for the awkward summary. This demonstrates what I mean:

% mkdir foo
% cd foo
% (cd .. && rmdir foo)
% cd $(port dir subversion)
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
error getting working directory name: no such file or directory
    while executing
    invoked from within
"set current_portdir [pwd]"
    (file "/opt/local/bin/port" line 4857)

This error only makes sense when invoking port(1) without specifying a port, since it looks for a Portfile in the current working directory.

I assume the same behavior would be observed with the -D option.

Change History (7)

comment:1 Changed 8 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:2 Changed 8 years ago by cooljeanius (Eric Gallager)

I found that if you split up the (cd .. && rmdir foo) into two separate commands, this error doesn't happen:

Local-Admins-MacBook-Pro:foo ericgallager$ cd ..
Local-Admins-MacBook-Pro:MacPorts-fork ericgallager$ rmdir foo
Local-Admins-MacBook-Pro:MacPorts-fork ericgallager$ cd $(port dir subversion)


Local-Admins-MacBook-Pro:foo ericgallager$ (cd .. && rmdir foo)
Local-Admins-MacBook-Pro:foo ericgallager$ cd $(port dir subversion)

I guess that's because in the first case, the directory isn't actually getting deleted out from under you...

comment:3 Changed 6 years ago by Ionic (Mihai Moldovan)

No, you're changing other semantics.

() spawns a subshell and cd .. does only apply to this child process. The parent's PWD is not affected (and will stay the deleted directory.)

comment:4 Changed 6 years ago by Ionic (Mihai Moldovan)

This issue should be elevated to CRITICAL because it affects me!

In all seriousness, though, it's annoying. I often cd $(port work foo) to patch/do random stuff. While cleaning explicitly or running other operations on the port foo, this directory gets deleted and re-created (as it should be.)

Due to port's inability to work in an "invalid" $PWD, I have to cd . to get into the newly created dir (a zsh-only feature, I assume) and run the port operation again.

Last edited 6 years ago by Ionic (Mihai Moldovan) (previous) (diff)

comment:5 Changed 6 years ago by Ionic (Mihai Moldovan)

Cc: ionic@… added

comment:6 Changed 2 years ago by chrstphrchvz (Christopher Chavez)

Cc: chrstphrchvz added

comment:7 Changed 2 years ago by chrstphrchvz (Christopher Chavez)

There are a number of times this error has been reported/mentioned/encountered: #24687, #33687, #33953, #41668, #52600, #58739, various mailing list posts.

I think at a minimum there should be a more helpful error message to suggest the workaround of cding to an existent/accessible directory, e.g. cd ~.

Last edited 2 years ago by chrstphrchvz (Christopher Chavez) (previous) (diff)
Note: See TracTickets for help on using tickets.