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

nikola build succeeds in building a site without a config file #1575

Closed
Kwpolska opened this issue Jan 10, 2015 · 5 comments
Closed

nikola build succeeds in building a site without a config file #1575

Kwpolska opened this issue Jan 10, 2015 · 5 comments
Assignees
Milestone

Comments

@Kwpolska
Copy link
Member

cc @felixfontein

@Kwpolska Kwpolska added this to the v7.3.0 milestone Jan 10, 2015
@felixfontein
Copy link
Contributor

If I understand the old code correctly (https://github.com/getnikola/nikola/blob/007a0e7cf611ef9e377644fca8600ff2b258d8df/nikola/__main__.py), that has already been the situation before adding the switch to specify the configuration file's location. Now it outputs a warning, though.

@felixfontein
Copy link
Contributor

If we want this not to work, I'd suggest to supply the Nikola object with information whether the config file was there, and let it decide (based on the command to run) whether it should bail out or not. The Nikola object should ask the command object whether it needs a config file or not, so that it is possible to write command plugins which don't need a config file (if we hard-code the commands which don't need one, as it is at the moment for commands where the warning isn't printed, that's not possible).

@Kwpolska Kwpolska self-assigned this Jan 10, 2015
Kwpolska added a commit that referenced this issue Jan 10, 2015
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
@Kwpolska
Copy link
Member Author

Actually, no. This is caused by b985b2f.

Before this commit, nikola build did this if there was no config:

[2015-01-10T10:11:14Z] ERROR: Nikola: This command needs to run inside an existing Nikola site.

The culprit:

    config['__configuration_filename__'] = conf_filename

What is wrong with this? You see, we determine whether or not a site is configured by site.configured = bool(config). Before we do that, we remove the variables added in __main__.py and make them attributes of the site object.

In order to fix this error and restore the old behavior (coming from __main__.py for doit commands (incl. nikola build) or execute() in nikola-specific Commands), we need to also remove __configuration_filename__ from the config dict before attempting to check whether or not the site is configured.

Another change I made, trying to use a different config file that does not exist is now an error that leads to sys.exit(1).

@felixfontein
Copy link
Contributor

Ah, ok, that's one way to do it. But your change now breaks nikola/plugins/check.py, because that looks for site.config['__configuration_filename__']. I'll fix that.

@felixfontein
Copy link
Contributor

Ah, you already changed that. Sorry, didn't see that...

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

No branches or pull requests

2 participants