-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add support for MINETEST_USERDATA environment variable #12639
Conversation
9c5c68f
to
b38487c
Compare
Please document this feature here: https://github.com/minetest/minetest/blob/master/doc/minetest.6 Also a notice in "Paths" (https://github.com/minetest/minetest/blob/master/README.md#paths) might be helpful - either a general one, or mentioning the command line and environment variable methods. EDIT: Also what about Windows users? |
b38487c
to
e5c2e12
Compare
I decided to change the variable name to |
e5c2e12
to
1cbc72d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it a little odd that $MINETEST_USER_PATH
is not actually the path to minetest's user directory, but rather the path to the directory where minetest's user directory is created. My first reaction upon seeing this was "oh cool there's now a way to put my tests the data in .local/share
" but you can only kinda do that... because it'll still make a hidden directory. For that reason, my first instinct when testing was to try ~/.local/share/minetest
... but in fact this will fail, because MT will only try to create the .minetest dir and not any of its parents. This yields the not very useful error of
Cannot create user data directory
I feel like if we're going to have a feature like this, we should
- Allow minetest to create the full path, not just the final directory
- Let the user specify the full path to the data, not the path to
.minetest
's parent.
If we don't do this, I think the documentation should be updated. "Path to Minetest user data directory." doesn't read as the parent dir, whereas something like "Path to search for the Minetest user data directory" might be clearer. I will leave that determination to the PR author and/or any other coredevs who want to chime in.
EDIT One other benefit of pointing to the actual dir is the possibility that someone can make a folder of various MT setups, ie minetest-1
, minetest-2
, minetest-3
, etc. They can do that in its current state, but it's going to require a useless hidden secondary folder which makes the management of those configs more of a pain.
I agree that specifying the actual directory would be better. The reason for the current behavior of Minetest creating a However before I update this, I'll wait for other devs to chime in and confirm this is a good approach to take for this PR. |
I totally missed that part about nested directories. Indeed, I agree with @Df458 that the variable should point directly to the user data, and not its parent directory. |
1cbc72d
to
c91717b
Compare
So I adjusted the code to have In separate commit, I adjusted |
You could recursively call |
Okay, I understand. I'll utilize |
c91717b
to
4ad1833
Compare
As I was implementing this, I discovered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on Linux with a trivial change in initializePaths()
to enforce system paths due to RUN_IN_PLACE configuration/build.
Works. The environment variable now points exactly to the desired location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at CI you will also see that the build is broken
The MINETEST_USER_PATH environment variable can be used to define a custom path for Minetest user data. If MINETEST_USER_PATH is empty or unset, the HOME (or APPDATA on Windows) environment variable is used as the default user data path; this ensures backwards compatibility with existing user setups.
The fs::CreateDir() function will fail if any parent directories in the path do not exist. Using the fs::CreateAllDirs() function allows us to create the user data directory along with any missing parent directories in the path.
4ad1833
to
35da40e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
The MINETEST_USERDATA environment variable can be used to defined a
custom path for Minetest user data. If MINETEST_USERDATA is empty or
unset, the HOME environment variable is used as the default user data
path; this ensures backwards compatibility with existing user setups.