Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filed to load file on iPad #38

Open
Ce1este opened this issue Nov 13, 2023 · 7 comments
Open

filed to load file on iPad #38

Ce1este opened this issue Nov 13, 2023 · 7 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Ce1este
Copy link

Ce1este commented Nov 13, 2023

All features work fine on my computer(windows) and Android phone.
When it comes to the iPad, everything works fine when using only the features of Typst itself, but I get error when I use the files in the Obsidian library or import typst packages.

filed to load file (access denied)
    ╭─[/07 DataBase/Obsidian插件使用方法/85 Typst Renderer.md:33:9]
    │
 33 │   image("/Resource_Library/408/磁盘.svg", width: 70%),
    │         ────────────────────────────────────  
    │                                                
    │ 
    │ Help: cannot read file outside of project root
you can adjust the project root with the --root argument
────╯
filed to load file (access denied)
   ╭─[/04 学习笔记/考研/数学/三角函数.md:6:9]
   │
 6 │ #import "@preview/cetz:0.1.2"
   │         ─────────────────────  
   │                                 
   │ 
   │ Help: cannot read file outside of project root
you can adjust the project root with the --root argument
───╯

I've noticed that this problem seems to have been fixed in #9, is there something wrong with the way I'm using it on iPad?

@Ce1este
Copy link
Author

Ce1este commented Nov 13, 2023

By the way, on iPad this plugin didn't download the missing libraries like it did on the computer, so I manually imported all the library files to .obsidian\plugins\typst\packages\preview
Could this be the cause of the problem?

@fenjalien fenjalien added the bug Something isn't working label Nov 13, 2023
@fenjalien
Copy link
Owner

Unfortunately I don't have access to an apple device so I haven't been able to do any testing on iOS. Could you give me some more details?

All features work fine on my computer(windows) and Android phone.
When it comes to the iPad, everything works fine when using only the features of Typst itself, but I get error when I use the files in the Obsidian library or import typst packages.

Are you saying that with everything (and I mean EVERYTHING) the same except the platform is either iPad or Windows, it works on Windows but not iPad? If not what are the differences or what happens if everything is the same? Could show your iOS, Obsidian, plugin versions and any other plugins you have enabled?

With the errors I would guess its Typst refusing to access the file before actually attempting to read the file. Could you change the first file path to a file that doesn't exist but in the same folder? Something like "/Resource_Library/408/a.svg", it should hopefully give the same error. I'm not sure whats happening with the second error. Could you try moving the code to different places in the vault, diffierent folders or at the root?

By the way, on iPad this plugin didn't download the missing libraries like it did on the computer

How do you know this and what error does it give?

I manually imported all the library files to .obsidian\plugins\typst\packages\preview
Could this be the cause of the problem?

I doubt this is the root cause but make sure they're in the same structure as in the computer.

@Ce1este
Copy link
Author

Ce1este commented Nov 14, 2023

First, I don't think this error is caused by other plugins, because when I disable all other plugins and only keep the Typst Renderer, I get the same error message.

But if you're going to need it, here's my list of plugins on the ipad. (from community-plugins.json)

[
  "dataview",
  "typst",
  "music-code-blocks",
  "adamantine-pick",
  "obsidian-admonition",
  "obsidian-advanced-uri",
  "aosr",
  "avatar",
  "obsidian-banners",
  "blur",
  "blindfold-obsidian",
  "buttons",
  "code-styler",
  "customizable-sidebar",
  "dbfolder",
  "new-tab-default-page",
  "obsidian-dynamic-background",
  "obsidian-dynamic-toc",
  "obsidian-excalidraw-plugin",
  "extract-url",
  "exercises",
  "file-tree-alternative",
  "home-tab",
  "vextab",
  "various-complements",
  "obsidian-title-serial-number-plugin",
  "obsidian-timeline",
  "obsidian-tikzjax",
  "templater-obsidian",
  "obsidian-style-settings",
  "table-extended",
  "sheets",
  "obsidian-read-it-later",
  "obsidian-quiet-outline",
  "pseudocode-in-obs",
  "obsidian42-brat",
  "obsidian-memos",
  "obsidian-markmind",
  "obsidian-functionplot",
  "obsidian-columns",
  "multi-column-markdown",
  "obsidian-minimal-settings",
  "mathlinks",
  "media-extended",
  "math-booster",
  "link-favicon",
  "language-translator",
  "obsidian-image-layouts",
  "obsidian-image-gallery",
  "obsidian-icon-shortcodes"
]

With the errors I would guess its Typst refusing to access the file before actually attempting to read the file. Could you change the first file path to a file that doesn't exist but in the same folder? Something like "/Resource_Library/408/a.svg", it should hopefully give the same error. I'm not sure whats happening with the second error. Could you try moving the code to different places in the vault, diffierent folders or at the root?

For /Resource_Library/408/a.svg, It does give the same error.
And I move the code to different places in the vault, It still give the same error.
I think your guess is right, Typst doesn't seem to have access to any files.


I'm using "Windows 11 Version 22H2 22621.1992" and "iPadOS 17.2".
I use the git tool to synchronize the contents of files in the repository between the three platforms(Windows,Android,iPadOS), which ensures that the file structure is the same.
In order to keep the settings of the three platforms from interfering with each other, I set up separate config folders for each of them. For windows is .obsidian, for iPad is .obsidian.iPad, for Android is .obsidian.android.

By the way, on iPad this plugin didn't download the missing libraries like it did on the computer

On the computer, typst automatically detected the missing libraries and then downloaded them automatically, on the iPad I waited for a long time and nothing happened, so I copied all contents from \.obsidian\plugins\typst\packages to \.obsidian.android\plugins\typst\packages and \.obsidian.iPad\plugins\typst\packages.
This works on Android, so I think it's probably not due to a different file structure either.

I'm sorry that I don't know much about how the Obsidian plugin actually works, so I can only judge it superficially: it seems to me that the way access permissions to files are determined on iOS/iPadOS is not quite the same as on Windows/Android, which may be the cause of the problem.

Finally, thank you for your work on this plugin, it has helped me a lot.
If you need any other information, I will try my best to provide it.

@fenjalien
Copy link
Owner

Thanks for the info! I've had a look at the code as an access denied error can't be thrown on mobile on a file read attempt, only before within the Typst compiler. Its a bug the wrong error is thrown however the actual error still gets printed to the console.

Would you be able to get access to the console on your iPad and show the error? I'm not sure how exactly to do this for apple devices as I only have android, but this: https://github.com/KjellConnelly/obsidian-dev-tools might be something. Could you also try in a new vault only on your iPad with only the plugin?

@Ce1este
Copy link
Author

Ce1este commented Nov 14, 2023

I'm not sure I'm using it the right way. Is this it?

Clipboard 2023年11月14日 20 11

blob:capacitor://localhost/4c89bc45-daf2-46bd-a015-ac7b8737e182:1:2529

@Ce1este
Copy link
Author

Ce1este commented Nov 14, 2023

图像

When the packages cannot be found, an error "package not found" will be reported.
Manually importing the package files to the corresponding location will result in an error "failed to load file(access denied)".

It seems that Typst can detect whether the package exists, but it cannot proceed to the next step correctly?

From opening Obsidian and loading the plugin to opening the file containing Typst only these two types of errors occur.

@fenjalien
Copy link
Owner

Thank you! I'm not sure I can diagnose this issue without an apple device with me as there should be more error messages than this...

I have a bad feeling its because the way in which files are read is only available on android and not iOS. Which is a great shame as there was literally no other way to do it.

It seems that Typst can detect whether the package exists, but it cannot proceed to the next step correctly?

Yes, the compiler works on a separate thread where the file reading is different (and not working) but the main thread can read the file system fine and tell the compiler which packages are available. If the package isn't available the main thread attempts to download the package then restart the compiler. I'm assuming you do have an internet connection in which case its receiving a 404 error meaning the package doesn't exist (which it definitely does). Any other issues in fetching the package should result in a different error.

@fenjalien fenjalien added the help wanted Extra attention is needed label Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants