1

On my main account on my main Mac, the open command is not functioning only for the sub directories under ~/Documents/. Namely, open ~/Documents/test does not open that directory in Finder.app, but instead ~/ is shown in Finder.

I have been using the command for many years but I have never seen this issue.

What I tried are

  1. Removing the ~/Documents directory but the new ~/Documents which macOS automatically creates has the same issue.
  2. Tried another account and found that it worked. So the problem happens for the main user only.
  3. Rebooting does not help.
  4. Relaunching Finder does not help.
  5. Changing the shell to bash or tcsh does not help. (I usually use zsh.)
  6. Opening other sub directories in ~/Library or ~/Music works perfect.
  7. Checking/unchecking "Terminal.app" in System Preferences > Security & Privacy > Privacy Full Disk Access (update 1)
  8. Cmd + Shift + G in Finder cannot change the location to any subdirectories in ~/Documents. (update 2)

In addition, probably the same (unknown) reason causes another issue.

Any application dialogs like "Open" or "Save" cannot accept drag & drop for sub directories under ~/Documents. Namely, if I want to save a text file from TextEdit and drag & drop ~/Documents/test in the save dialog, this location is not selected but instead ~/ is shown.

Does anyone have a nice idea to resolve or debug this issue?


(update 3)

Probably due to the facts that I forced to remove ~/Documents by using sudo and that Finder recreated a new directory, the xattr of ~/Documents looks to be not properly set. How do I restore the settings? (XXX is my user name)

$ ls -led Library Music Desktop Movies Documents
drwx------@ 451 XXX  staff  14432 Jul 20 19:36 Desktop
 0: group:everyone deny delete
drwxr-xr-x    2 XXX  staff     64 Jul 23 11:09 Documents
drwx------@ 132 XXX  staff   4224 May  8 14:52 Library
 0: group:everyone deny delete
drwx------+  31 XXX  staff    992 Feb 26  2020 Movies
 0: group:everyone deny delete
drwx------+   8 XXX  staff    256 Mar 14  2020 Music
 0: group:everyone deny delete

The new directory contains GarageBand, iMovie, Keynote, ... TextEdit that are graphically shown in Finder, but they do not exist when executing ls in Terminal.

$ ls -a Documents
.  ..

~/Desktop/GarageBand is a link(?) to /Users/XXX/Library/Containers/com.apple.garageband10/Data.


(update 4)

I found that

$ open ~/Documents/test

was not functioning (i.e., ~ is shown in Finder), but

$ sudo mv ~/Documents ~/Documents_org
$ open ~/Documents_org/test

did work.

So the issue looks to be caused by the special directory settings of macOS (12.4) and my broken ~/Documents.


(update 5)

  • My main account
$ mdls Documents
kMDItemContentType             = ""
kMDItemFSContentChangeDate     = (null)
kMDItemFSCreationDate          = (null)
kMDItemFSCreatorCode           = ""
kMDItemFSFinderFlags           = (null)
kMDItemFSHasCustomIcon         = (null)
kMDItemFSInvisible             = 0
kMDItemFSIsExtensionHidden     = (null)
kMDItemFSIsStationery          = (null)
kMDItemFSLabel                 = (null)
kMDItemFSName                  = (null)
kMDItemFSNodeCount             = (null)
kMDItemFSOwnerGroupID          = (null)
kMDItemFSOwnerUserID           = (null)
kMDItemFSSize                  = (null)
kMDItemFSTypeCode              = ""
kMDItemInterestingDate_Ranking = 2022-07-23 00:00:00 +0000
kMDItemLastUsedDate            = 2022-07-23 03:01:10 +0000
kMDItemLastUsedDate_Ranking    = 2022-07-23 00:00:00 +0000
kMDItemUseCount                = 2
kMDItemUsedDates               = (
    "2022-07-22 15:00:00 +0000"
)
  • Another account
% mdls Documents 
_kMDItemDisplayNameWithExtensions      = "Documents"
kMDItemAlternateNames                  = (
    Documents
)
kMDItemContentCreationDate             = 1970-01-01 00:00:00 +0000
kMDItemContentCreationDate_Ranking     = 
kMDItemContentModificationDate         = 2021-04-12 07:57:09 +0000
kMDItemContentModificationDate_Ranking = 2021-04-12 00:00:00 +0000
kMDItemContentType                     = "public.folder"
kMDItemContentTypeTree                 = (
    "public.folder",
    "public.directory",
    "public.item"
)
kMDItemDateAdded                       = 2021-03-31 16:24:18 +0000
kMDItemDateAdded_Ranking               = 2021-03-31 00:00:00 +0000
kMDItemDisplayName                     = "Documents"
kMDItemDocumentIdentifier              = 0
kMDItemFSContentChangeDate             = 2021-04-12 07:57:09 +0000
kMDItemFSCreationDate                  = 1970-01-01 00:00:00 +0000
kMDItemFSCreatorCode                   = ""
kMDItemFSFinderFlags                   = 0
kMDItemFSHasCustomIcon                 = (null)
kMDItemFSInvisible                     = 0
kMDItemFSIsExtensionHidden             = 0
kMDItemFSIsStationery                  = (null)
kMDItemFSLabel                         = 0
kMDItemFSName                          = "Documents"
kMDItemFSNodeCount                     = 1
kMDItemFSOwnerGroupID                  = 20
kMDItemFSOwnerUserID                   = 502
kMDItemFSSize                          = (null)
kMDItemFSTypeCode                      = ""
kMDItemInterestingDate_Ranking         = 2021-04-12 00:00:00 +0000
kMDItemKind                            = "Folder"
5
  • Does Terminal have Full Disk Access (or at least access to Documents) in the Security&Privacy preference pane?
    – nohillside
    Jul 22, 2022 at 7:43
  • Thank you for the remind. I forgot to add it in the list above. Yes, I checked it and repeated unchecking and checking, but it did not help. Jul 22, 2022 at 8:02
  • The original question updated. Jul 22, 2022 at 8:15
  • Which access rights and ACLs are set on Documents?
    – nohillside
    Jul 22, 2022 at 8:48
  • That's a good point. I did not check it. I updated the original post. Jul 23, 2022 at 2:15

1 Answer 1

0

Reading a "Related" post below, I found a solution to restore the Documents folder setting.

Spotlight can't open a folder inside ~/Documents/

The solution is

  1. Make new temporally directories ~/Documents_org and ~/Desktop_org and move the contents of ~/Documents and ~/Desktop into them.
  2. Enable iCloud Drive sync for "Desktop & Documents Folders" in System Preferences and wait for the sync to be finished.
  3. Disable the iCloud Drive sync.
  4. Move back the ~/Documents_org and ~/Desktop_org contents to the original dilectroies.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .