Moving .gnucash and friends from $HOME to XDG_DATA_HOME (and impact on other applications like KMyMoney)
John Ralls
jralls at ceridwen.fremont.ca.us
Thu Aug 24 06:11:48 EDT 2017
> On Aug 24, 2017, at 8:57 AM, Geert Janssens <geert.gnucash at kobaltwit.be> wrote:
>
> On woensdag 23 augustus 2017 23:21:23 CEST John Ralls wrote:
>> A new default should apply only to new installations and should be
>> overridden by $GNC_DOT_DIR and $AQBANKING_HOME; we should continue to
>> include ~/.gnucash and ~/.aqbanking in the default search and use the first
>> instance of the config file we find.
>>
> While that is conservative and safe, it would also require us to support the
> outdated directories forever and by extension make our code more complicated
> for that same period. So I'm not in favor of this strategy.
>
> And I'm not the only one. I have come across several applications in my long
> use of linux that have chosen not to do that either. Two come to mind
> immediately: libreoffice has changed user data directories with every major
> release for as long as I have used it. It has always copied the old one and
> didn't even bother telling the user about this. KMail did a similar migration
> twice, and informed the me about it on each occasion.
>
> So I think to point of view to take here is gnucash 2.8 is a new application
> that knows how to import settings from an older application (which happens to
> be gnucash 2.6 or older). At some point in the future nobody will still be
> using the old application at which point the user can decide to drop the
> configuration that old app used (I think nobody does that in real life
> though).
>
> I agree an override option should exist indeed. Not in the least because
> you're using it on OS X :)
>
> On the other hand I think GNC_DOT_DIR is tied way too much to the old
> directory format and I prefer to change it to GNC_DATA_HOME (as GNC_HOME is
> already in use to point at the base installation directory).
>
>> The XDG environment variables are appropriate in the Gnome and KDE desktop
>> environments on Linux and pretty much nowhere else. Perhaps the best
>> approach would be to set reasonable defaults per OS and allow them to be
>> overridden with a CMake variable and configure argument.
>>
> The per OS defaults are a good suggestion. On linux and compatible that is
> XDG_DATA_HOME/Gnucash, on Windows CSIDL_APPDATA\Gnucash. I'm only missing this
> on OS X. Is there a function in the Quarz framework that would return ~/
> Library/Application Support/ so a similar default path can be created ? I'd
> want the defaults to be such that no environment variable should be set to get
> them.
>
> About the override in Cmake or configure, I doubt that makes much sense. These
> directories have no use during build, only at runtime*. And at runtime they
> can be overridden by GNC_DATA_HOME and AQBANKING_HOME.
>
> Geert
>
> * Strictly speaking I should say "should have no use during build".
> Unfortunately compiling the guile sources will cause the user_data_dir
> functions to be run. It's guile's way of evaluating whether dynamically loaded
> modules won't call other guile sources that need to be compiled :(
> I'm still evaluating whether this is bad for my new code or not.
Re backwards compat, OK, I guess. Moving the default for GnuCash isn't really the issue, it's AQBanking. Unless we convince Martin to go along we're either going to have a hack like linking or to support ~/.aqbanking forever.
Re GNC_DOT_DIR on Mac: But if GnuCash sets the default data directory to ~/Library/Application Support then I won't need the environment variable override.
The reason for providing a CMake/configure override is because people build GnuCash on platforms besides the 3 we overtly support including the various BSDs, True64, and Solaris. There was even somebody running it on OpenVMS a few years ago, but we haven't heard from him in a long time. I think some of the BSDs distribute GnuCash binaries, and it would be courteous to provide those packagers with a convenient way to set up GnuCash for whatever their defaults are.
We'll also need a fallback on Linux if XDG_DATA_HOME isn't defined or GnuCash will barf because it can't create /gnucash.
The Cocoa key for ~/Library/Application Support is NSFileManager::NSApplicationSupportDirectory. There's example code at https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/ManagingFIlesandDirectories/ManagingFIlesandDirectories.html <https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/ManagingFIlesandDirectories/ManagingFIlesandDirectories.html>.
Regards,
John Ralls
More information about the gnucash-devel
mailing list