Skip to content
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

Path to config file should not be relative to root dir #1022

Closed
satakuma opened this issue May 11, 2020 · 1 comment
Closed

Path to config file should not be relative to root dir #1022

satakuma opened this issue May 11, 2020 · 1 comment

Comments

@satakuma
Copy link
Contributor

Bug Report

Command line description -c, --config <config> Path to a config file other than config.toml [default: config.toml] doesn't suggest, that the path to a config file will be treated relatively to the root directory of a project.

/// Get and parse the config.
/// If it doesn't succeed, exit
pub fn get_config(path: &Path, filename: &str) -> Config {
match Config::from_file(path.join(filename)) {
Ok(c) => c,
Err(e) => {
println!("Failed to load {}", filename);
println!("Error: {}", e);
::std::process::exit(1);
}
}
}

The misunderstanding occurs only when one wants to specify both the root and config parameters with values other than the default ones. Personally I think, that in this situation it's probably most likely that the user wants to use a custom config file from other location than the project directory.

Note that the second command line parameter taking a path as a value, output_dir, is not treated relatively to the project directory.

Environment

Zola version: zola 0.10.1

Expected Behavior

The path should be treated relatively to the current work directory with the current CLI description.

Step to reproduce

Simply create a new site and then try to build it being outside of it:

zola init test
zola -r test/ -c test/config.toml build

what results in:

Building site...
Failed to load test/config.toml
Error: No `"config.toml"` file found. Are you in the right directory?

Notes

I would change the description to something like:
Path to a config file other than config.toml in the project directory,
and then treat the path relatively to the cwd.
I can implement this solution if it's ok.

@Keats
Copy link
Collaborator

Keats commented May 11, 2020

Sounds ok to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants