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

Error in _overwrite_pygments_css: DirectoryHTMLBuilder' object has no attribute 'globalcontext' #1096

Closed
choldgraf opened this issue Jan 1, 2023 · 6 comments · Fixed by #1115
Labels
kind: bug Something isn't working

Comments

@choldgraf
Copy link
Collaborator

choldgraf commented Jan 1, 2023

In building the documentation with Sphinx 5.3, I am occasionally getting this error message:

Handler <function _overwrite_pygments_css at 0x7f971a03caf0> for event 'build-finished' threw an exception (exception: 'DirectoryHTMLBuilder' object has no attribute 'globalcontext')

I believe it's coming from this line:

theme_name = app.config.html_theme_options.get(
style_key, app.builder.globalcontext.get(f"theme_{style_key}")
)

It still seems to be in-use by Sphinx, so not really sure what's going on:

https://github.com/sphinx-doc/sphinx/blob/ff202240abebd12b1e12c9052e11f785c401e725/sphinx/builders/html/__init__.py#L569-L573

Maybe we need to add a similar conditional?

@choldgraf choldgraf added the kind: bug Something isn't working label Jan 1, 2023
@drammock
Copy link
Collaborator

drammock commented Jan 3, 2023

hmm, hard to debug occasional failures. If you can come up with a test that fails reliably I can work on a fix. Currently I can't replicate with nox -s docs

@choldgraf
Copy link
Collaborator Author

Indeed - I found it hard to replicate as well but it happened multiple times. I figured it'd be better to capture the error message in an issue in case others come across the same problem.

If nobody else encounters this in the next 3-6 months, maybe we can just close this?

@12rambau
Copy link
Collaborator

12rambau commented Jan 8, 2023

fun fact since friday I got it one 1 build out of 2 systematically when building this doc: https://github.com/12rambau/sepal_ui

but only on my mac computer. I don't see the error on my linux machine. Note that to solve it I use the good old hammer technique: run it ... twice

nox -s docs

@choldgraf
Copy link
Collaborator Author

It seems like an easy fix might be to add a check for whether globalcontext exists before trying to use it. Maybe we could give that a shot and see if the intermittent errors go away

@drammock
Copy link
Collaborator

drammock commented Jan 9, 2023 via email

@drammock
Copy link
Collaborator

I can't replicate this (on Linux) even with @12rambau's tip of running nox -s docs twice in a row (I just ran it 3 times and all succeeded). Since he's also only able to reproduce on mac (not linux) I'm going to give up for now and go with the easy fix @choldgraf put into #1115... it's frustrating not to know why this is happening but I think the fix is probably fine/harmless even if unsatisfying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants