Bug 439125

Summary: Opening file on Windows starts in %SYSTEM_ROOT% (system32) instead of user home
Product: [Applications] kate Reporter: jm.ouwerkerk
Component: applicationAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: christoph, jpmbatrina01, paul.m.w.johnson, vonreth
Priority: NOR    
Version First Reported In: 20.12.2   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed/Implemented In: 23.12.0
Sentry Crash Report:

Description jm.ouwerkerk 2021-06-24 18:50:42 UTC
SUMMARY


STEPS TO REPRODUCE
1. Install Kate app via MS App store
2. Launch Kate
3. Attempt to Open a file from UI

OBSERVED RESULT

The Open file dialog starts in C:\Windows\System32 (%SYSTEM_ROOT%)

EXPECTED RESULT

I would expect it to start in my user home directory.


SOFTWARE/OS VERSIONS
Windows: 
Edition	Windows 10 Enterprise
Version	20H2
Installed on	‎17/‎03/‎2021
OS build	19042.1052
Experience	Windows Feature Experience Pack 120.2212.2020.0


ADDITIONAL INFORMATION
Comment 1 Jan Paul Batrina 2021-06-26 04:44:31 UTC
Confirmed with Kate 21.04.0 intalled via the MS Store on June 25, 2021.

The origin of this bug is similar to that of https://bugs.kde.org/show_bug.cgi?id=425136 . However, it seems that when kate is installed through the MS Store, the kate binary is launched directly which means the working directory cannot be set to the home directory.

FWIW, the same thing happens with e.g. Okular, but Kile does not have this bug since it uses the home folder as an explicit default/fallback location (https://github.com/KDE/kile/blob/3e727f38dcb2ddc111bdc76b07b45c57919f96af/src/widgets/filebrowserwidget.cpp#L60).
Comment 2 Christoph Cullmann 2021-06-26 14:03:58 UTC
I searched for a way to set the working dir for the appx stuff, failed so far.

That would be in my eyes the only "usable" solution.

We can't know inside the application if the current working dir is a good fallback or not, in most cases, e.g. if you started from terminal it is, here it isn't.
Comment 3 Jan Paul Batrina 2021-06-26 16:22:34 UTC
I'm not sure if it works (and it might be a bit too complicated/overkill), but maybe the workingDirectory config option from the Package Support Framework fixup (https://docs.microsoft.com/en-us/windows/msix/psf/package-support-framework#create-a-configuration-file) might be what we're looking for? 

The linked documentation says "package-relative path" though, so I'm not sure if the home folder can be used.
Comment 4 Christoph Cullmann 2021-06-26 17:59:00 UTC
Hmm, that could be some solution, perhaps it is possible to use some variable inside this to get to the user profile.

CCin Hannah, perhaps she has some idea.
Comment 5 Paul Johnson 2021-08-25 01:26:33 UTC
I confirm this using Kate 21.04.0 when installed from MS Store. In the process of updating, I decided to uninstall the Store version and get the latest portable build and merge it into my portable programs structure.

Using 21.08.0 for Windows, portable build, the default paths for opening and saving files are now the location of the Kate binary file.
Comment 6 Bug Janitor Service 2023-08-28 18:33:16 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1290
Comment 7 Christoph Cullmann 2023-08-28 18:55:37 UTC
Git commit 88af55db389cc35dd274220426c74a1714c8aa1e by Christoph Cullmann.
Committed on 28/08/2023 at 20:55.
Pushed by cullmann into branch 'master'.

start open dialog in home if not started from terminal

M  +4    -0    apps/lib/kateviewmanager.cpp

https://invent.kde.org/utilities/kate/-/commit/88af55db389cc35dd274220426c74a1714c8aa1e