getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.6k stars 444 forks source link

AttributeError: 'str' object has no attribute 'task' #3406

Open cosmoscalibur opened 4 years ago

cosmoscalibur commented 4 years ago

Environment

Python Version: 3.6.8

Nikola Version: 8.0.4

Operating System: Linux Mint 19

Description:

Steps:

Instead, in new post this is no reproducible. If nikola clean is executed before nikola build, no problem appear.

Kwpolska commented 4 years ago
  1. Paste full traceback.
  2. Does this happen in a clean site?
  3. Show the versions (mainly of doit) with pip freeze.
cosmoscalibur commented 4 years ago

1.

Scanning posts.......done!
.  copy_assets:output/assets/css/code.css
.  render_posts:timeline_changes
.  render_posts:cache/posts/cosmogonia-griega.html
.  render_taxonomies:output/categories/cat_ciencia/index.html
.  render_taxonomies:output/2013/index.html
.  render_taxonomies:output/categories/arqueoastronomia/index.html
.  render_taxonomies:output/categories/astronomia/index.html
.  render_taxonomies:output/categories/griegos/index.html
.  render_taxonomies:output/categories/historia-de-la-astronomia/index.html
.  render_taxonomies:output/categories/cosmogonia/index.html
.  render_taxonomies:output/categories/mitologia/index.html
.  render_taxonomies:output/index-6.html
Traceback (most recent call last):
  File "/home/cosmoscalibur/anaconda/envs/blog/lib/python3.6/site-packages/doit/doit_cmd.py", line 177, in run
    return command.parse_execute(args)
  File "/home/cosmoscalibur/anaconda/envs/blog/lib/python3.6/site-packages/doit/cmd_base.py", line 127, in parse_execute
    return self.execute(params, args)
  File "/home/cosmoscalibur/anaconda/envs/blog/lib/python3.6/site-packages/doit/cmd_base.py", line 420, in execute
    return self._execute(**exec_params)
  File "/home/cosmoscalibur/anaconda/envs/blog/lib/python3.6/site-packages/doit/cmd_run.py", line 260, in _execute
    return runner.run_all(self.control.task_dispatcher())
  File "/home/cosmoscalibur/anaconda/envs/blog/lib/python3.6/site-packages/doit/runner.py", line 256, in run_all
    self.run_tasks(task_dispatcher)
  File "/home/cosmoscalibur/anaconda/envs/blog/lib/python3.6/site-packages/doit/runner.py", line 219, in run_tasks
    if not self.select_task(node, task_dispatcher.tasks):
  File "/home/cosmoscalibur/anaconda/envs/blog/lib/python3.6/site-packages/doit/runner.py", line 107, in select_task
    task = node.task
AttributeError: 'str' object has no attribute 'task'
  1. When use nikola clean before, there is no problem.
aiohttp==3.6.2
argh==0.26.2
astroid==2.3.3
async-timeout==3.0.1
attrs==19.3.0
Babel==2.7.0
backcall==0.1.0
bleach==3.1.0
blinker==1.4
certifi==2019.11.28
chardet==3.0.4
cloudpickle==1.2.2
decorator==4.4.2
defusedxml==0.6.0
doc8==0.8.0
docutils==0.15.2
doit==0.31.1
entrypoints==0.3
idna==2.8
idna-ssl==1.1.0
importlib-metadata==1.5.0
ipykernel==5.1.4
ipython==7.13.0
ipython-genutils==0.2.0
isort==4.3.21
jedi==0.16.0
Jinja2==2.11.1
jsonschema==3.2.0
jupyter-client==6.1.2
jupyter-core==4.6.3
lazy-object-proxy==1.4.3
Logbook==1.5.3
lxml==4.4.1
Mako==1.1.0
Markdown==3.1.1
MarkupSafe==1.1.1
mccabe==0.6.1
mistune==0.8.4
multidict==4.7.3
natsort==6.0.0
nbconvert==5.6.1
nbformat==5.0.4
Nikola==8.0.4
notebook==6.0.3
olefile==0.46
pandocfilters==1.4.2
parso==0.6.2
pathtools==0.1.2
pbr==5.4.2
pexpect==4.8.0
pickleshare==0.7.5
piexif==1.1.3
Pillow==6.2.1
prometheus-client==0.7.1
prompt-toolkit==3.0.4
ptyprocess==0.6.0
Pygments==2.4.2
pyinotify==0.9.6
pylint==2.4.4
pyrsistent==0.16.0
PyRSS2Gen==1.1
python-dateutil==2.8.1
pytz==2019.3
PyYAML==5.2
pyzmq==18.1.1
requests==2.22.0
restructuredtext-lint==1.3.0
rstcheck==3.3.1
Send2Trash==1.5.0
six==1.13.0
stevedore==1.30.1
terminado==0.8.3
testpath==0.4.4
tornado==6.0.4
traitlets==4.3.3
typed-ast==1.4.0
typing-extensions==3.7.4.1
Unidecode==1.1.1
urllib3==1.25.6
watchdog==0.9.0
wcwidth==0.1.9
webencodings==0.5.1
wrapt==1.11.2
Yapsy==1.12.2
yarl==1.3.0
zipp==2.2.0
Kwpolska commented 4 years ago

I can reproduce this bug with your site (https://github.com/cosmoscalibur/cosmoscalibur.github.io), or with your posts copied to a base site, but I’m not really sure what it is caused by. The string in question is doit’s "hold on", which means all tasks are waiting for something. I don’t have this issue with my own site though.

Kwpolska commented 4 years ago

@schettino72 Do you have any ideas for debugging this? It looks like all tasks wait on something, but this something cannot be provided, so doit tries to execute that "hold on" placeholder.

schettino72 commented 4 years ago

"hold on" should happen only when using multiprocessing... I guess thats not your case.

So I would guess the problem is circular dependency of tasks. doit usually get these problems, but with more dynamic stuff it might not be able to detect it... On control.py, just above yield "hold on" try to look into the content of self.waiting. I dont remember exactly the data structure but you should be able to find the tasks involved.

doit has --pdb option to drop into debugger, not sure how to enable that with nikola command line.

fvicent commented 1 year ago

I just ran across this issue in my Nikola site. Indeed, it seems to be caused by circular dependency when using the post-list directive in two different posts which have the same tag you're trying to display posts from. Not on the first nor second build, but on the third one. If you clean the cache the issue disappears.

Steps to reproduce in a clean site:

  1. Run nikola new_post -t "Post A"
  2. Run nikola new_post -t "Post B"
  3. Inside posts/post-a.rst write:

    .. title: Post A
    .. slug: post-a
    .. date: 2022-10-14 01:15:53 UTC-03:00
    .. tags: mytag
    .. category: 
    .. link: 
    .. description: 
    .. type: text
    
    .. post-list::
       :tags: mytag
  4. Inside posts/post-b.rst write:

    .. title: Post B
    .. slug: post-b
    .. date: 2022-10-14 01:16:10 UTC-03:00
    .. tags: mytag
    .. category: 
    .. link: 
    .. description: 
    .. type: text
    
    .. post-list::
       :tags: mytag
  5. Run nikola build for the first time. The site will build successfully with the expected behavior: nikola Screenshot 2022-10-14 013840
  6. Run nikola build again, no errors yet.
  7. Run nikola build once more and you'll get:
    (env) C:\Users\franc\Documents\nikola\nikola-dev\errsite>nikola build
    Scanning posts........done!
    Traceback (most recent call last):
    File "C:\Users\franc\Documents\nikola\nikola-dev\env\lib\site-packages\doit\doit_cmd.py", line 295, in run
    return command.parse_execute(args)
    File "C:\Users\franc\Documents\nikola\nikola-dev\env\lib\site-packages\doit\cmd_base.py", line 151, in parse_execute
    return self.execute(params, args)
    File "C:\Users\franc\Documents\nikola\nikola-dev\env\lib\site-packages\doit\cmd_base.py", line 612, in execute
    return self._execute(**exec_params)
    File "C:\Users\franc\Documents\nikola\nikola-dev\env\lib\site-packages\doit\cmd_run.py", line 265, in _execute
    return runner.run_all(self.control.task_dispatcher())
    File "C:\Users\franc\Documents\nikola\nikola-dev\env\lib\site-packages\doit\runner.py", line 255, in run_all
    self.run_tasks(task_dispatcher)
    File "C:\Users\franc\Documents\nikola\nikola-dev\env\lib\site-packages\doit\runner.py", line 218, in run_tasks
    if not self.select_task(node, task_dispatcher.tasks):
    File "C:\Users\franc\Documents\nikola\nikola-dev\env\lib\site-packages\doit\runner.py", line 107, in select_task
    task = node.task
    AttributeError: 'str' object has no attribute 'task'

Not sure why building succeeds a couple of times and fails on the third attempt, or if this kind of cross-reference in post-list is even supposed to work. I'm willing to help if you have any thoughts on this.

msghens commented 1 year ago

I have this issue also. I removed all references of:

.. post-list:: :tags: mytag

AttributeError: 'str' object has no attribute 'task' issue goes away.