holzschu / Carnets

Carnets is a stand-alone Jupyter notebook server and client. Edit your notebooks on the go, even where there is no network.
https://holzschu.github.io/Carnets_Jupyter/
BSD 3-Clause "New" or "Revised" License
546 stars 31 forks source link

No way to approve carnets to access file folder #316

Open abazeman opened 8 months ago

abazeman commented 8 months ago

I image

Anyone knows how to get iPhone to allow Carnets to access files and create new files? The app did not ask permission and I do not know how to grant it permission without the prompt

holzschu commented 8 months ago

I think the first question is: where are you creating the file? in which folder?

nedgar commented 6 months ago

I'm seeing something similar after first install of Carnets on iOS 17.2.1. It's acting as if Files and Folders permission has not been granted, and I don't see the option to grant that. Perhaps the app's manifest doesn't declare that requirement?

New notebook (+ icon):

image

Trying to open Welcome notebook in Carnets folder:

image

holzschu commented 6 months ago

Thanks a lot for the screenshots. I'm extremely puzzled (also because it does not happen often, especially not when I'm testing).

In the AppStore reviews, someone mentionned that changing the "Document Storage" option for Carnets in the Settings App to "On my iPhone" instead of "iCloud Drive" solved this issue.

nedgar commented 6 months ago

Hmm, I tried that but the result is the same. Happy to have a screen share session some time next week if that helps. 

holzschu commented 6 months ago

That would be great. Let me have a look at the code first to identify possible causes. Do you have access to the local directories ("on my iPad/Carnets", or "on my iPad/Another App")?

nedgar commented 6 months ago

It can list and show the files and folders, but apparently can’t read or write files. Not sure why he Carnets/Welcome notebook isn’t showing. I saw it earlier. Looks like it’s trying to read from iCloud documents folder, not local Carnet folder. And there is no Carnets folder in iCloud, just local.

holzschu commented 5 months ago

Are you telling me that Carnets can not even create a notebook inside "On my iPad/Carnets"? (and if so, could you send me a screenshot, so I can escalate the issue with Apple?) Also, what do you mean by "Looks like it’s trying to read from iCloud documents folder, not local Carnet folder"?

nedgar commented 5 months ago

My mistake, I assumed it was trying to use an iCloud/Carnets folder because the URL shown in the error dialog was file:///private/var/mobile/Library/Mobile%20Documents/iCloud~AsheKub~Carnets/Documents/welcome/Welcome to Carnets.ipynb, but I guess iCloud~AsheKub~Carnets is just a way of identifying you as owner of the Carnets folder in local Files/Folders on device.

I tried uninstalling / reinstalling the Carnets app. The Carnets folder was deleted (or hidden) on uninstall. After reinstall, it reappeared but empty. I am now able to create a notebook, evaluate an expression, and save the notebook. If I try Save As, the prompt for path name has: private/var/mobile/Containers/Data/Applicaton/<UUID>/Documents/Untitled. If I accept, then it is saved OK and shows as Untitled.ipynb under On My iPhone/Carnets.

The path above is different than that in the URL from the error dialog.

Also, I don't see any way to access the Welcome notebook. Is it normally added to the local Carnets folder under Documents/welcome?

nedgar commented 5 months ago

I've copied the welcome/* files from the repo to a new Carnets folder in iCloud, and tried to open the welcome notebook from there. It opens OK but gives the warning about not having access to the "directory around this notebook" (wording suggestion: "the containing directory"). I don't see any "unlock directory" label, but the rightmost button in toolbar, with folder icon and arrow (suggesting import), allowed me to "open" the welcome folder. It then restarted the server / reloaded the page, with images showing.

tonydavidcray commented 5 months ago

Just found Carnets and am keen to get it running, but can confirm the exact same issues as nedgar

holzschu commented 5 months ago

Please keep sending detailed description of the issue, with the location of the directory with the issue and screenshots showing the error messages (also, what system version are you using). If it's an issue with iCloud access, it's different from an issue with access to local folders. From your descriptions, it's an issue that happens randomly, and from what I can see there's Apple software that behaves differently from what its documentation says. Any kind of hint can help in understanding where the issue is and how to work around it.

nedgar commented 5 months ago

@tonydavidcray good to have your input too. Does reinstalling Carnets help?

tonydavidcray commented 5 months ago

Deleting and reinstalling resulted in a little more progress. Still seems to be some odd issues with permissions with the file manager.

I have now successfully adding a .ipynb file to my icloud drive from VSCode on my mac. File is able to be opened on Carnets and runs as expected. Saving on iPad also now syncs to the mac Cloud Drive and updates in VSCode.

tonydavidcray commented 5 months ago

Creating a new notebook on iPad still results in a permissions error. iPad M1 12.9”. iPadOS 17.1.2

holzschu commented 5 months ago

Hi, the TestFlight version of Carnets-with-Scipy: https://testflight.apple.com/join/UbNIjkjp has changed how it access files in "iCloud folder/Carnets" and also prints more information about why the access fails. Could you please test it and report the error?

nedgar commented 5 months ago

Looks good! I shared a few screenshots with suggestions. Lmk if you didn't get them.

holzschu commented 5 months ago

I'm glad to know it works for you; I didn't get the screenshots. If the github user interface keeps removing them, you can send them by e-mail to: carnets_jupyter@icloud.com

nedgar commented 5 months ago

I meant I sent the screenshots from the in-app hook.

holzschu commented 5 months ago

Oh! Thank you, I got them. Most of your suggestions are about things that are not under my control. In short: iOS has a strong file security. An app cannot access a file from another app, unless the user explicitly grants permission. Clicking on the file is granting permission. But that means that the file browser you see at the beginning is not something that the app can control, it's something managed by the system (Carnets calls it, but that's all it can do). I could not find any ways (so far) to guide this file browser, for example by telling it to open a specific directory or to not start with "Recents". I'd love to, but there are no documented calls for that. I've been trying for years, I tried again in the past weeks, nothing works. And to answer your other question: when you clicked on a file, you granted permission for that file only. So you can edit its content (good) but not read files nearby, or create new files, or even rename the file. All of that requires folder permission, which you need to grant separately.

nedgar commented 5 months ago

Thanks for clarifying the constraints you have to deal with. I think the "directory around this file" warning could be clarified, but the behaviour makes sense now. Maybe just "other files in the containing folder cannot be accessed unless you grant permission". Note that the files app uses "folder" rather than "directory".

nedgar commented 5 months ago

Do you plan to release this "with scipi" version as a separate app or just as an upgrade?

nedgar commented 5 months ago

I'm also wondering what the UX for the welcome notebook is intended to be. I was only able to get it by copying from the repo. I'd expect it to appear in the Carnets folder, added in app install or on first run.

holzschu commented 5 months ago

Hi, to answer your questions:

Eiche63 commented 2 months ago

Hi, I‘ve got the same problem after downloading version 1.8.3 from the App Store (iOS Version 17.4.1 on M1 iPad). After the first start I saw an error message briefly appearing stating „You have no permission to create a Documents folder“ (or documents?), before the other error messages already reported in this thread to Carnets popped up. I renamed the Documents folder inside the app, could then create a notebook, start Python etc. That means, that after installing the welcome folder was NOT copied to „iCloud/Carnets“.

But I could not restart the app, had to reboot the iPad for that. Now a have an uploading problem to iCloud, the synchronization is stuck (which is imo connected to creating an illegal folder in the iCloud). I removed the app, deleted my notebooks and copies, and downloaded it again. Now I get only a blank screen which disappears after some seconds. The app seems still to be alive, can switch to a blank screen. Will try to disconnect from iCloud and reconnect.

holzschu commented 2 months ago

Hi, you're the first to report the issue with version 1.8.3. The first error message should have been something like: "Could not access iCloud: Carnets is unable to access your iCloud folder: (...)", or maybe "Error accessing iCloud: ...".

It's clear that iCloud does not like people creating or removing folders in its place. I actually don't understand how you could "rename the Documents folder inside the app". I'm going to see if your crash reports appear in my console.