GNOME Bugzilla – Bug 503722
Do not store data in Vista's HOME folder, use AppData instead
Last modified: 2018-06-29 21:56:29 UTC
Vista's %HOME% folder, e.g. c:\users\andy only contains special folders or shortcuts to them, it does not contain application data. It would be a lot more compliant to Vista's guidelines if GnuCash used its own subfolder in (Local)AppData. Or in other words, Visata %HOME% <> GnuCash %HOME% but rather something like GnuCash %HOME% = Vista %LOCALAPPDATA%\GnuCash Vista's %HOME% folder contains e.g. the special Music, Pictures, Documents folders as well as a few 'OS' folders like AppData. I have configured Vista to show all files (including hidden ones) and when I go from my Documents to my Pictures, I have to browse through all the GnuCash private application data files to find my Pictures. For now I have made a workaround in gnucash.bat by adding set HOME=%LOCALAPPDATA%\GnuCash mkdir %HOME% This workaround still has some open issues: 1) should this be %APPDATA% to allow for roaming users? 2) it probably needs some migration code as well to preserve preferences
Does your workaround also work for XP? Windows 7?
No idea; I only have vista installed at home. Maybe somebody else can test/comment?
Sounds like this should be done in the gnucash.cmd file. Is there an easy way to determine what version the OS is so that HOME can be set properly?
I am using 2.2.9 and Windows 7. Same issue, lots of Gnucash files in my user folder.
It would be better to use the proper Windows API function to determine where user data should be stored. SHGetFolderPath <http://msdn.microsoft.com/en-us/library/bb762181(v=VS.85).aspx>, which works on Windows 2000 and later, should be called with nFolder set to CSIDL_APPDATA. Glib has a g_get_user_config_dir function which appears to call this underneath. Don't be tempted to use g_get_user_data_dir: it returns the path to the user's My Documents directory (doh!)
Just wanted to verify that Andy's workaround works perfectly on Windows 7 x64. Thanks!
I have been looking into this. LOCALAPPDATA is a new environment variable in Windows, starting from Windows Vista. So it can't be used on Windows XP. Additionally, as of GnuCash 2.4 there is no longer a 'gnucash.bat' so that way of setting environment variables won't work anymore. But there should be other ways to do something similar now. * locate the file C:\Program Files\GnuCash\etc\gnucash\environment (you may have to adjust the path if you didn't install GnuCash in its default location) * inside this file, add a line: GNC_DOT_DIR=$LOCALAPPDATA/GnuCash * if you wish to keep the info that was stored in .gnucash for your future GnuCash runs, move the directory <your home dir>\.gnucash to <your local app data dir> and rename it to GnuCash Unfortunatly I don't have Vista or Windows 7 so I can't verify these steps. Can you please test this with GnuCash 2.4 and see if that works ? Be sure you have removed the old .gnucash (after taking a backup if you care for its contents) before running the test. If that works, I will try to get that worked out in code.
Small correction to the above workaround: You should add the line GNC_DOT_DIR={LOCALAPPDATA}/GnuCash The one with the $ sign mentioned in comment 7 won't work. And by the way, Windows XP users can use APPDATA instead, like this: GNC_DOT_DIR={APPDATA}/GnuCash I verified the XP case and that works. Can someone with a Vista or Windows 7 system run the following commands in a console windows and post the output in a comment here, please ? echo %APPDATA% echo %LOCALAPPDATA% Thanks
To be complete, I should add that the trick above only solves part of the problem: it will get rid of the .gnucash directory. GnuCash on Windows comes bundled with a lot of gnome libraries which also create directories in the wrong place. On my system I currently have: - .banking - .gconf - .gconfd - .gnome2 - .gnome2_private - .gnucash All of these are generated by GnuCash or one of the bundled libraries. The .gnucash one can relatively easily be eliminated. I will have to search for the others.
I don't think that the local application data directory is the correct place to store the user's data. For a computer not part of a domain, it doesn't make any difference; but when the computer is on a domain, the user's appdata folder is replicated to other computers in the domain, and so follows them around the network as they log into different computers; the local appdata is not. MS' guidelines say that only user settings applicable to a single computer (e.g., selected screen resolution in a game) should be stored in the corresponding local directory.
Quick update, .gconfd is hardcoded in the source code of GConf (one of the gnome libraries used by GnuCash). Changing it would require us to patch GConf we ship with GnuCash. A one-line patch would suffice: --- gconf-internals.c-org 2011-01-15 14:36:34.000000000 +0100 +++ gconf-internals.c 2011-01-15 14:36:56.000000000 +0100 @@ -700,7 +700,7 @@ if (quark != 0) return g_quark_to_string (quark); - home_copy = g_strdup (g_get_home_dir ()); + home_copy = g_strdup (g_get_user_config_dir ()); /* Replace backslashes with forward slashes */ for (p = home_copy; *p; p++) .gconf can be overridden via a configuration file that ships with it. This config file doesn't seem to cope well with the APPDATA environment variable on XP, so likely it won't work with Vista or W7's LOCALAPPDATA either. However, the above patch would automatically fix the default location for .gconf as well. Also like Sam already suggests, I think we can safely use APPDATA which would make GnuCash roaming friendly. Roaming is used to provide a user an environment that is independent of the PC he's sitting in front of. So in a roaming environment, it makes sense a user's GnuCash preferences travel with him. If roaming is not used, it makes no difference if we use APPDATA or LOCALAPPDATA, so we could just as well settle for APPDATA. I haven't looked at the .gnome2* or .banking directories yet.
As predicted: modifying the environment file solves the .gnucash folder but not the others. For now I've created a gnucash.cmd file next to the gnucash.exe and modified the start menu to call the .cmd instead of the .exe Content-wise it's just set HOME=%APPDATA%\GnuCash mkdir %HOME% call gnucash.exe I've tested this on Vista.
Just out of curiosity, why didn't you alter the environment file as I outlined ? There's no need for a wrapper script like you have created, at least not on Windows XP.
> As predicted: modifying the environment file solves > the .gnucash folder but not the others. I did modify it; but I only saw an effect on the one gnucash folder; not on the others. With the etc/environment file modified, I still have .gconf & .gconfd & .gnome2 & .gnome2_private. My testing on Vista & Win7 (with the released 2.4 version; not a nightly build) fully confirmed the behavior discussed in previous comments. PS. I mentioned my gnucash.cmd workaround in case other users were upgrading and wanted a tested scenario to follow. It's just a workaround as on Vista the cmd file results in an extra window. Conclusion: you are on the right track but additionally a solution is needed for the bundled libraries.
Ok, I understand your comment 12 now. Thanks.
*** Bug 580166 has been marked as a duplicate of this bug. ***
A clever user reported on the mailing list to have changed the HOME environment variable via the environment file and reported that all directories now got properly relocated. So instead of GNC_DOT_DIR={APPDATA}/GnuCash add the line HOME={APPDATA}/GnuCash in the environment file, and all the dot-directories mentioned in comment 9 should now be generated under %APPDATA%\GnuCash. If you wish to keep your preferences, copy the old directories in there first before restarting GnuCash.
*** Bug 568175 has been marked as a duplicate of this bug. ***
*** Bug 642739 has been marked as a duplicate of this bug. ***
Just for clarity, I'll add here that bug 642739 is not a duplicate and has been restored in its independent state.
> A clever user reported on the mailing list to have changed the HOME environment > variable via the environment file and reported that all directories now got > properly relocated. > > So instead of > GNC_DOT_DIR={APPDATA}/GnuCash > add the line > HOME={APPDATA}/GnuCash I can confirm that this works fine in Windows 7 and XP. I make the change manually every time I install or update GnuCash.
(In reply to comment #17) > A clever user reported on the mailing list to have changed the HOME environment > variable via the environment file and reported that all directories now got > properly relocated. > > So instead of > GNC_DOT_DIR={APPDATA}/GnuCash > add the line > HOME={APPDATA}/GnuCash > > in the environment file, and all the dot-directories mentioned in comment 9 > should now be generated under %APPDATA%\GnuCash. > > If you wish to keep your preferences, copy the old directories in there first > before restarting GnuCash. Guys, I have little knowledge on programing, and I'm trying to solve this problem, but I'm not succeeding. I successfully found, opened and edited the environment file, but after writing the line "HOME={APPDATA}/GnuCash" nothing happened. How exactly should I write the line "HOME={APPDATA}/GnuCash"? In the end of the environment file? The beginning? What is the exact syntax? Should I use " or ', or any other sign?
Sorry for the slow reply. The line should be added at the end of the environment file, without any quotes. So you should add this: HOME={APPDATA}/GnuCash
Is there a chance that this can get fixed in some release of GnuCash? I'd think it's a pretty straightforward change to the distributed environment file.
(In reply to comment #23) > Sorry for the slow reply. > > The line should be added at the end of the environment file, without any > quotes. So you should add this: > HOME={APPDATA}/GnuCash Geert, I successfully changed the environment file, and it worked perfectly. Thanks for the answer.
From a recent gnucash-user conversation, it appears that the {APPDATA}/GnuCash directory needs to be created before GnuCash runs for the first time. When the bug is fixed, that will need to be done at setup time. Here's the start of the thread: http://lists.gnucash.org/pipermail/gnucash-user/2011-February/038525.html the conclusion isn't in the archives yet.
Aloha. New user to GnuCash but this fix does not seem to work for my installation on Vista. I needed to change the file permissions to save the environment file with the HOME={APPDATA}/GnuCash line but each time I start the Program the same directories are created in the Home folder.
(In reply to comment #27) > Aloha. New user to GnuCash but this fix does not seem to work for my > installation on Vista. I needed to change the file permissions to save the > environment file with the HOME={APPDATA}/GnuCash line but each time I start the > Program the same directories are created in the Home folder. @Mutts: Changing permissions makes sense, so that's likely not the problem -- did you add the line to the environment file before you ran GnuCash for the first time? (See Randy's comment above.)
Unfortunately I did not add the file before the first run (at the time I wasn't aware of the issue). Can this be remedied with a complete uninstall at this point? If not, would there be any problem with setting the relevant folders/files as hidden?
(In reply to comment #29) > Unfortunately I did not add the file before the first run (at the time I wasn't > aware of the issue). Can this be remedied with a complete uninstall at this > point? If not, would there be any problem with setting the relevant > folders/files as hidden? A complete uninstall would probably be the best plan. If there's data you want to keep, you could back up your existing GnuCash folders first and then move them to the AppData folder when you edit the new environment file. I think I once tried marking the folders as hidden, but found that GnuCash wouldn't remember my window size/location settings.
(In reply to comment #30) > (In reply to comment #29) > > Unfortunately I did not add the file before the first run (at the time I wasn't > > aware of the issue). Can this be remedied with a complete uninstall at this > > point? If not, would there be any problem with setting the relevant > > folders/files as hidden? > > A complete uninstall would probably be the best plan. If there's data you want > to keep, you could back up your existing GnuCash folders first and then move > them to the AppData folder when you edit the new environment file. > > I think I once tried marking the folders as hidden, but found that GnuCash > wouldn't remember my window size/location settings. Hello Guys. Just to give feedback: I have just formatted my notebook and re-installed GnuCash 2.4.4. Again, this "folder" problem occurred. I changed the environment file before the first run, but it didn't work. What I did after that was to create a "GnuCash" folder directly under APPDATA\Roaming, and moved the created folders into it. The next time I opened GnuCash, no more folders appeared. So, there was no need to reinstall GnuCash. By the way, I use Windows 7.
(In reply to comment #31) > (In reply to comment #30) > > (In reply to comment #29) > > > Unfortunately I did not add the file before the first run (at the time I wasn't > > > aware of the issue). Can this be remedied with a complete uninstall at this > > > point? If not, would there be any problem with setting the relevant > > > folders/files as hidden? > > > > A complete uninstall would probably be the best plan. If there's data you want > > to keep, you could back up your existing GnuCash folders first and then move > > them to the AppData folder when you edit the new environment file. > > > > I think I once tried marking the folders as hidden, but found that GnuCash > > wouldn't remember my window size/location settings. > > Hello Guys. Just to give feedback: > > I have just formatted my notebook and re-installed GnuCash 2.4.4. Again, this > "folder" problem occurred. I changed the environment file before the first run, > but it didn't work. What I did after that was to create a "GnuCash" folder > directly under APPDATA\Roaming, and moved the created folders into it. The next > time I opened GnuCash, no more folders appeared. So, there was no need to > reinstall GnuCash. By the way, I use Windows 7. Thanks Paulo, that did the trick on my Vista system :).
A very old bug that will get fixed for gnucash 2.8. After installing that version gnucash will use AppData(Roaming)\GnuCash by default instead of %HOME%\.gnucash. If there is still a %HOME%\.gnucash its contents will be migrated to AppData(Roaming)\GnuCash. I'm afraid those that had added HOME={APPDATA}/GnuCash to their environment file will need to manually do this migration. That means you'll need to copy the contents of APPDATA\Roaming\Gnucash\.gnucash to APPDATA\Roaming\Gnucash (so one level higher). Note also that from 2.8 onwards you should no longer modify environment directly. Instead create a second file called environment.local next to it and make your changes in there. That file should have the same layout: [Variables] var1=value1 .... The advantage is you'll no longer have to do this after each installation/update. This local file will never be overwritten. Gnucash 2.8 is planned for the end of this year but we'll start the beta program soon and you may want to test the 2.7 intermediary releases when they come out and file bugs so 2.8 can be the best gnucash ever :)
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=503722. Please update any external references or bookmarks.