Opened 11 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)
Port:

Description

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
"pwd"
    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.

Attachments (1)

Screen Shot 2022-04-11 at 22.14.11.png (312.2 KB) - added by cooljeanius (Eric Gallager) 2 years ago.
screenshot of MacPorts (and related binaries) having been granted Full Disk Access in System Preferences

Download all attachments as: .zip

Change History (10)

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

Cc: egall@… added

Cc Me!

comment:2 Changed 11 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)

vs.

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 9 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 9 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 9 years ago by Ionic (Mihai Moldovan) (previous) (diff)

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

Cc: ionic@… added

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

Cc: chrstphrchvz added

comment:7 Changed 5 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 5 years ago by chrstphrchvz (Christopher Chavez) (previous) (diff)

comment:8 Changed 2 years ago by JDLH (Jim DeLaHunt)

This problem just affected me. In my case, MacPorts Base and all ports appeared to be fine. My current working directory was a subdirectory of ~/Desktop/, and for some reason I can no longer list the contents of ~/Desktop/ with ls. This apparently was enough to make pwd unusable by MacPorts Base. The symptoms of this ticket followed. I fixed it by changing my current working directory to ~.

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

You may need to grant MacPorts access to your Home directory (and any relevant subdirectories) in the "Privacy" section of the "Security & Privacy" system prefpane for this to work; I'll attach a screenshot of what it ought to look like.

Changed 2 years ago by cooljeanius (Eric Gallager)

screenshot of MacPorts (and related binaries) having been granted Full Disk Access in System Preferences

Note: See TracTickets for help on using tickets.