Issues When Reading a Folder Saved in Local Dropbox Folder Using JXA

Hello, community.

I am running the following code inside an Execute a JavaScript For Automation action, and I don't get any output. The following function lists the contents of a given directory.

(() => {

    const main = () => {
        return getDirectoryContents("~/Dropbox/Reference/Quiver.qvlibrary")
    }


    // getDirectoryContents :: FilePath -> IO [FilePath]
    const getDirectoryContents = fp =>
        ObjC.deepUnwrap(
            $.NSFileManager.defaultManager
            .contentsOfDirectoryAtPathError(
                $(fp)
                .stringByStandardizingPath, null
            )
        );

    return main()

})();

However, when I paste the code in VSC I can successfully execute it. Does someone or perhaps @peternlewis know whether we can read files or folders saved in Dropbox with KM JXA action ?

P.D.: I am able to read other files and folders (not saved in the Dropbox folder).

I am running macOS ventura with a Mac book air m1.

The Dropbox folder is weird. Also it moved into a new location recently which may be related.

It could be some permission issues. It may also require Full Disk Access permission (does VSC have Full Disk Permission?).

1 Like

Yes, it does.

I added KM app (in addition to the engine) to the full disk access permission, and now it works !

Thank you.

3 Likes