akazukin5151 / koneko

Browse pixiv in the terminal using kitty's icat to display images (in the terminal!)
https://koneko.readthedocs.io/en/latest/
GNU General Public License v3.0
51 stars 3 forks source link

koneko doesn't create/populate its ~/.local/share/ directory [Debian/Ubuntu] #20

Closed PPAChao closed 2 years ago

PPAChao commented 2 years ago

Installing via pip install koneko, koneko fails to set up ~/.local/share/koneko/ and to copy the necessary files there (pixiv-url.desktop, example_config.ini, /pics/, /cache).

When I first installed it, the login wouldn't work: no error message, nothing would happen after logging in in the browser (Chromium). I tried manually creating ~/.local/share/koneko/pixiv-url.desktop (and the directory itself), and now xdg-open would properly forward the pixiv:// url to koneko—which promptly responded with “login failed”. After digging around in the source code here on github, I realised that nothing in ~/.local/share/koneko/ was where it should be. I cloned this git respository and manually copied pixiv-url.desktop, example_config.ini, and /pics/ to ~/.local/share/koneko/ and now I could log in and koneko launched. When trying to use it however, it reported not being able to access ~/.local/share/koneko/cache/. Manually create this subdirectory once again solved this problem, and some functions of koneko now worked. There seems to be some kind of problem with koneko not creating & populating its ~/.local/share directory. ~/.config/koneko/ (and config.ini there) on the other hand was automatically created just fine.

This problem was encountered on two separate machines, running Xubuntu 20.04 and Debian 11 respectively, without any nonstandard permissions sets for ~/, and using the most recent Python 3 versions from their respective repositories.

akazukin5151 commented 2 years ago

Ah, I get it. The files are only copied in setup.py in the root dir, but not when using pip install. You can confirm this by running python setup.py install on the repo's root and verify it works. A fix is incoming...

akazukin5151 commented 2 years ago

Commit 72869a18026518961ea0aa03063063fe23f78854 should've fixed it. I've pushed it as version 0.12.3 on PyPI, so pip install koneko should work now (make sure it is 0.12.3). Thanks for the bug report!

PPAChao commented 2 years ago

Thanks for the quick fix! It installs fine now on both machines.

Koneko still doesn't create ~/.local/share/koneko/cache though. When trying to view a Pixiv user's illustrations, the program crashes with a message about that cache directory being missing. Creating it manually wit mkdir fixes this.

akazukin5151 commented 2 years ago

That's strange, because it should already be checking if the cache exists. If I delete the cache dir, it does create the dir and download the images before showing them. Can you post the error message? Does it happen if you delete the cache dir?

PPAChao commented 2 years ago

To test this, I uninstalled koneko, manually deleted the entire ~/.local/share/koneko/ directory, and reinstalled koneko via pip. It launches fine, and ~/.local/share/koneko has been re-created automatically. (Only content right now: /pics/). Attempting to view artist illustrations crashes with the following output:

  File "/home/ppa/.local/bin/koneko", line 8, in <module>
    sys.exit(_main())
  File "/home/ppa/.local/lib/python3.8/site-packages/koneko/__main__.py", line 25, in _main
    func(args)
  File "/home/ppa/.local/lib/python3.8/site-packages/koneko/main.py", line 45, in main_loop
    return func()
  File "/home/ppa/.local/lib/python3.8/site-packages/koneko/main.py", line 102, in start
    self._save_history()
  File "/home/ppa/.local/lib/python3.8/site-packages/koneko/main.py", line 125, in _save_history
    logger = utils.setup_history_log()
  File "/home/ppa/.local/lib/python3.8/site-packages/koneko/utils.py", line 32, in setup_history_log
    handler = RotatingFileHandler(KONEKODIR / 'history', maxBytes=1e6, backupCount=3)
  File "/usr/lib/python3.8/logging/handlers.py", line 148, in __init__
    BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
  File "/usr/lib/python3.8/logging/handlers.py", line 55, in __init__
    logging.FileHandler.__init__(self, filename, mode, encoding, delay)
  File "/usr/lib/python3.8/logging/__init__.py", line 1147, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib/python3.8/logging/__init__.py", line 1176, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/home/ppa/.local/share/koneko/cache/history'

I manually create a subdirectory called "cache". Now, viewing that same artist's (id=3312701) illustrations works fine after restarting the program.

akazukin5151 commented 2 years ago

Ah, somehow I can reproduce it now. This should work, and python setup.py install should work too, so can you please try this before I upload to PyPI? Thanks

PPAChao commented 2 years ago

It works! I deleted /cache/, applied the patch, and now it's generating automatically.