Windows: Corrupted display and other problems
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.1k
- Forks
- 233
- Avg merge
- 1h 44m
- Merged PRs (30d)
- 1
Description
Describe the bug
I know that Windows isn't officially supported.
I am writing this in case you can trivially fix this.
Along the way I have discovered 2 other issues which seem trivial and you might benefit in solving anyway.
I have installed khal with pipx. I did the same with vdirsyncer. I configured both of them correctly. I am using both programs in linux so I tried my luck with Windows too.
I discovered 3 issues. I was able to hack around 2 of them. For the 3rd one I have no idea what is happening or how to solve it.
Issue 1
After a clean install ikhal will try to create the sqlite3 database at the default place. Namely, on Windows, C:\Users\<username>\.local\share\khal\khal.db. However, the last part of the path, khal.db, is created as a folder instead of as a file.
Current solution: Set ~/.local/share/khal/khal.db in the config. (the tilde vs the full path probably doesn't matter).
Issue 2
During startup, ikhal tries to figure out if the local calendar is modified and ends up in this code:
https://github.com/pimutils/khal/blob/106e4d013e33640cccccbed823c948f41027e2d0/khal/khalendar/vdir.py#L74-L79
The constant os.O_DIRECTORY isn't available on Windows and the program crashes.
Secondly, I tried to understand the logic of the function and it doesn't make sense in the context of a vdir calendar. The f variable wll point to a directory. On Windows, you can't os.open() a directory. It fails with PermissionError: [Errno 13] Permission denied:.
So I slightly changed the function to get it working with this diff:
index 2b3e688..07e75a3 100644
--- a/khal/khalendar/vdir.py
+++ b/khal/khalendar/vdir.py
@@ -71,18 +71,18 @@ def get_etag_from_file(f) -> str:
if hasattr(f, 'read'):
f.flush()
f = f.fileno()
- elif isinstance(f, str):
- flags = 0
- if os.path.isdir(f):
- flags = os.O_DIRECTORY
- f = os.open(f, flags)
- close_f = True
+ # elif isinstance(f, str):
+ # flags = 0
+ # if os.path.isdir(f):
+ # flags = os.O_DIRECTORY
+ # f = os.open(f, flags)
+ # close_f = True
# assure that all internal buffers associated with this file are
# written to disk
try:
- os.fsync(f)
- stat = os.fstat(f)
+ # os.fsync(f)
+ stat = os.stat(f)
finally:
if close_f:
os.close(f)
Issue 3
Finally, ikhal can now start. But the display is totally corrupted. Take a look at the attached screenshot.
Keep in mind, that I run a non-english Windows version (greek locale).
The display is corrupted both in cmd and in bash (from git for windows). Both are integrated in Terminal.
In bash, LANG is exported as en_GB.UTF-8.
OS, version, khal version and how you installed it:
- The output of khal --version: 0.11.3
- Installation method: pipx
- python version: 3.11.2
- OS: Windows 10
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce ikhal on Windows 10 with Python 3.11.2 and pipx, noting the default database path, startup failure, and corrupted display. Review khal/khalendar/vdir.py around the linked get_etag_from_file code, then investigate the Windows Terminal and Greek-locale conditions. Done means the database is created correctly, startup completes, and ikhal renders normally in the reported terminals.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlite
- Domain
- cli, databases, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100