mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Improve the warning message when USERDATA_STRATEGY was not set during compilation and the binary was moved outside the workspace/crate that it was compiled from, show a warning when an invalid VELOREN_USERDATA_STRATEGY is used, and also actually make sure warnings from userdata selection are logged in voxygen (since the userdata folder needs to be selected to set up logging we have to rerun the selection after logging is set up so that any warnings will be logged).
This commit is contained in:
parent
bb26008074
commit
c8b55d3dcb
@ -41,7 +41,15 @@ pub fn userdata_dir(workspace: bool, strategy: Option<&str>, manifest_dir: &str)
|
||||
path.push("userdata");
|
||||
Some(path)
|
||||
},
|
||||
Some(_) => None, // TODO: panic? catch during compilation?
|
||||
Some(s) => {
|
||||
warn!(
|
||||
"Compiled with an invalid VELOREN_USERDATA_STRATEGY: \"{}\". \
|
||||
Valid values are unset, \"system\", and \"executable\". \
|
||||
Falling back to unset case.",
|
||||
s,
|
||||
);
|
||||
None
|
||||
},
|
||||
_ => None,
|
||||
})
|
||||
// 3. The CARGO_MANIFEST_DIR/userdata or CARGO_MANIFEST_DIR/../userdata depending on if a
|
||||
@ -61,10 +69,23 @@ pub fn userdata_dir(workspace: bool, strategy: Option<&str>, manifest_dir: &str)
|
||||
path
|
||||
} else {
|
||||
// otherwise warn and fallback to the executable strategy
|
||||
warn!("This binary was moved to outside the project folder where it was compiled and was not compiled with VELOREN_USERDATA_STRATEGY set to \"system\" or \"executable\". Falling back the to the \"executable\" strategy (the userdata folder will be placed in the same folder as the executable)");
|
||||
let project_path = path;
|
||||
let mut path = exe_path;
|
||||
path.pop();
|
||||
path.push("userdata");
|
||||
warn!(
|
||||
"This binary is outside the project folder where it was compiled ({}) \
|
||||
and was not compiled with VELOREN_USERDATA_STRATEGY set to \"system\" or \"executable\". \
|
||||
Falling back the to the \"executable\" strategy (the userdata folder will be placed in the \
|
||||
same folder as the executable: {}) \n\
|
||||
NOTE: You can manually select a userdata folder (overriding this automatic selection) by \
|
||||
setting the environment variable {} to the desired directory before running. \n\
|
||||
NOTE: If you have not moved the executable this can occur when using a custom cargo \
|
||||
target-dir that is not inside the project folder.",
|
||||
project_path.display(),
|
||||
path.display(),
|
||||
VELOREN_USERDATA_ENV,
|
||||
);
|
||||
path
|
||||
}
|
||||
})
|
||||
|
@ -44,6 +44,9 @@ fn main() {
|
||||
let log_filename = format!("{}_voxygen.log", now.format("%Y-%m-%d"));
|
||||
let _guards = common_frontend::init_stdout(Some((&logs_dir, &log_filename)));
|
||||
|
||||
// Re-run userdata selection so any warnings will be logged
|
||||
common_base::userdata_dir_workspace!();
|
||||
|
||||
info!("Using userdata dir at: {}", userdata_dir.display());
|
||||
|
||||
// Determine Voxygen's config directory either by env var or placed in veloren's
|
||||
|
Loading…
Reference in New Issue
Block a user