ahrm / sioyek

Sioyek is a PDF viewer with a focus on textbooks and research papers
https://sioyek.info/
GNU General Public License v3.0
7.22k stars 236 forks source link

[BUG] relative paths with --new-window argument #1065

Open life00 opened 7 months ago

life00 commented 7 months ago

I recently noticed a weird inconsistency when trying to open PDF files as new window with --new-window argument and also supplying the relative path to Sioyek. The problem was that it failed to recognize that relative path correctly.

I identified the reason and I am not completely sure if its a bug or it is on purpose. Here is how you can reproduce it

  1. Lets imagine a scenario where I open a.pdf in directory /files/ as the initial file with the command sioyek --new-window a.pdf (while I am inside /files/) that launches Sioyek.
  2. Then I also want to open b.pdf as another window but it is in directory /files/dir/ to which I previously navigate, so I run sioyek --new-window b.pdf (while being in /files/dir/)

The initial instance of sioyek will be supplied with this new path to file, however it will fail to open it because it is appending the relative path (being ./b.pdf) to the current working directory of the initial instance (being /files/), not the new temporary instance CWD, so it tries to open /files/b.pdf and fails.

The fact that I am still able to open PDF files inside of CWD of initial instance as new window confirms this theory (e.g. I can open c.pdf inside /files/ because it does not trigger the bug).

There is no issue when Sioyek is supplied with the full path to b.pdf, so it is not that critical, however I believe relative paths should still be handled correctly and that's why I report this issue.

davidbelius commented 3 months ago

I couldn't get --new-window to work and this post explained why (thanks @life00!). I'm on Windows 11 and giving a relative path to a PDF from powershell using command A below makes the sioyek icon in the taskbar blink, but does not open any new window nor does it open the document provided in the argument. But giving the absolute path as in command B works.

A PS C:\path to directory with pdf> & 'C:\long path with spaces\sioyek-release-windows-portable\sioyek-release-windows\sioyek.exe' --new-window '.\pdf filename (with spaces and special characters).pdf'

B PS C:\path to directory with pdf> & 'C:\long path with spaces\sioyek-release-windows-portable\sioyek-release-windows\sioyek.exe' --new-window 'c:\path to directory with pdf\pdf filename (with spaces and special characters).pdf'