-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XDG Base Directory Specification not followed #908
Comments
The homepage claims support of Linux and macOS. Perhaps it would be useful to use tags to differentiate between various priority levels of bugs, rather than treating minor bugs as "enhancements". Not sure how the application's config directory is handled on Windows, but I hope it is with APPDIR, and not the same dotfolder which aren't even hidden on Windows. |
@billop To be fair, the specification has nothing to do with Linux (the kernel). So this is not a defect/bug. But this is coming from someone who sometimes uses some Environment variables defined by the specification. |
Good point, I meant a mainstream linux distro, speaking of "Linux" as an OS. I assumed that Ghidra touting support for Linux meant that as well. |
This is blocking my attempt at packaging Ghidra for Flatpak, as the application expects to be installed in a directory which is writable by the user, which is not going to be the case for Flatpak or system-installed software. For reference: flathub/flathub#1068 |
How does XDG handle remote home directories? If you are storing a lot of large cached files in ~/.cache/, is there anything following the standard that will stop those files from being written to the remote location? |
Safe to assume it's handled better in those setups than a random dotfolder in $HOME. |
Ghidra's cache directory is not in $HOME... |
Do be more clear, I'm asking if XDG offers something similar to %LOCALAPPDATA% in Windows. We need to support "roaming profiles" and can't store large cached files in the user's home directory unless it can somehow be exempt from remote storage while in there like it can on Windows. That's why Ghidra's cache directory is currently in the far-from-ideal temp directory on linux. |
@ryanmkurtz I don't know anything about Windows, but it sounds like you want XDG_CACHE_HOME. It's described on the Arch wiki page which Billop referenced in the original post above, and this seems to be the official reference: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html Basically, if I defined XDG_CACHE_HOME to be the name of a directory, Ghidra should put all cache files recursively within that directory. (To be clear, the cache files would most appropriately go within that subdirectory, e.g. into |
@nsajko, thanks, that is my understanding too. And by default, that will be at |
Presumably whoever deployed Ghidra would set the XDG_CACHE_HOME environment variable. Basic Unix usage as far as I see. I'm not sure if you already know this, but in Unix (and Linux) environment variables commonly get inherited from the parent process, so it is enough to set the environment variable once in some config file. For example: In any case, I don't quite see what's the problem here, but I hope I'm helping. |
Actually the distro maintainers do not assume that the XDG variables are set, what happens generally when you develop an application that follows the XDG specification is that they try to use the XDG variables if they are set, if not they use what should be "the default" location. e.g: It should also be noted that there 5 directories/variables that are included in the XDG specification, but normally on most applications only XDG_CACHE_HOME, XDG_CONFIG_HOME and XDG_DATA_HOME are used. For more details on that I suggest XDG Base Directory. |
Please follow xdg to the letter. There is no reason to clutter the home directory with this stuff. |
Bumping this issue... it shouldn't be difficult to implement (check env var, otherwise default to the correct location - which is NOT ~/.ghidra) and the XDG spec should really be followed. Apps cluttering the home directory is extremely frustrating for end users. |
You know what. If I have time maybe I'll fix it and make a pull request. |
If it’s of any help, I’ve a small experiment here. Only ever tested briefly on Linux. |
Marking this |
@ryanmkurtz XDG is only relevant for one platform though, just like for example If anything, switching to XDG-BD is fixing a bug coming from the mistaken assumption the current approach is multiplatform. |
I know that it's only for Linux, but if we make a change, we will want to use the standard locations on all platforms, not just do something special for Linux (i.e., not create a We do not consider Ghidra creating a |
It maybe intended behavior, but maybe intend something better |
Four years since this issue was opened. XDG isn't a very big spec folks, you can read it in about 5 minutes. All I see in this thread is you making excuses, none of which are anywhere near acceptable, and the combined time it took you to type all of them would probably be less than it would have taken to fix this. |
I'm sure this will make it faster for the code to be written and merged. No, wait, the opposite. |
I imagine the big issue with this request is that it would require a solution tailored to each major platform we support. Currently Ghidra uses 1 model that is the same for all OSes. This makes working on the system simpler for the maintainers. While implementing XDG may be simple enough, reworking this part of the system to have a cohesive model for all OSes is less so. |
I think changing the directories for each platform would be pretty quick and easy, as would be incorporating the XDG environment variables for Linux and possibly macOS. There are non-obvious changes that would have to be made in addition to these easy things though too:
So, not the hardest thing in the world to accomplish, but also not a quick change to some hardcoded paths either. I'll bring this up again with the team though. |
If Ghidra was coded under the mistaken assumption that there's a cross-platform data storage location, then that's the root of the issue. Start there and work upwards. It's APPDATA on Windows, XDG basedir on Linux, and I don't know what it is on MacOS but probably XDG too.
Ideally, software should just not have any code that writes to the home directory at all. But the way lots of people are solving the "legacy location" issue is by having an environment variable that tells it the location of its data folder, and default to |
I'm working on this now and have a question for people who actually use XDG. For Ghidra's "user temp" and "user cache" directories, we have been putting them in |
If you do want to use tmpdir, then, once you've decided on either String prefix = "Ghidra";
Path temp = Files.createTempDirectory(java.io.tmpdir, prefix);
temp.toFile().deleteOnExit(); So no need to incorporate the user's name as far as I can see. |
Thank you. So is it an error to define Or maybe we don't need to control Ghidra's temp usage via XDG, and just have it always use Also, generally speaking, if |
My advice would be to get the value of Just out of interest, the value of XDG_RUNTIME_DIR on my system is
Correct. The basedir spec defines XDG_CONFIG_HOME as: "the base directory relative to which user-specific configuration files should be stored". In fact, that's what the |
Ok, thanks again! |
Describe the bug
Ghidra does not follow the XDG Base Directories Specification.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Following the XDG Base Directory Specification.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: