1

I'm using Nikola, a static website generator, to build a website. I am automating its building through Github Actions. I also wanted to use Pandoc to help convert my markdown to html, but I noted that Pandoc was not included in the original action. Therefore, I had to try to figure out myself how to include it. However, I've been thwarted time and again by FileNotFound errors.

First, I tried to edit the action so that it installed Pandoc on the Ubuntu environment. Below is my edited version of the action. I only added the Install Pandoc on Ubuntu step.

on: [push]

jobs:

    nikola-build:
       runs-on: ubuntu-latest
       steps:
       - name: Install Pandoc on Ubuntu
         run: sudo apt-get install -y pandoc

       - name: Check out
         uses: actions/checkout@v2

       - name: Build and Deploy Nikola
         uses: getnikola/nikola-action@v3
         with:
           dry_run: false

When this failed again informing me that Pandoc could not be found, I added a requirements.txt file to my repository:

Pandoc

I tried running the action again. Both installations—the action step I wrote and pip install pandoc—ran without any issues and were successful. And yet when it came to the step where Nikola starts to build the website, it seems that no matter what is done, it fails in rendering, because Pandoc cannot not be found:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/nikola/plugins/compile/pandoc.py", line 76, in compile
    subprocess.check_call(['pandoc', '-o', dest, source] + self._get_pandoc_options(source))
  File "/usr/local/lib/python3.8/subprocess.py", line 359, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/local/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/local/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'pandoc'

I've looked absolutely everywhere for solutions to similar problems, but they are few and outdated. I would greatly appreciate any insight into this problem, what is at fault, what I can do to fix it, etc.

  • 1
    There might be some issue with that install of pandoc which seems to have some evidence for not working correctly, and thus this answer on AskUbuntu recommends using pandoc's own package instead: https://askubuntu.com/a/687676/8 – mechanical_meat Nov 24 '21 at 20:43
  • Hi @mechanical_meat, thank you for your suggestion. I tried your tip with a fairly new version of Pandoc (2.14), and it downloaded successfully, but somehow it still could not find it with the same error above. I'm wondering if the installation location could be affecting this? E.g. could it be Nikola looking for it in the wrong location? – Cary Thurston Nov 24 '21 at 21:21
  • Quick research indicates this is somehow working with cabal -- because it's written in Haskell, I believe, so try this: https://askubuntu.com/a/33443/8 to get cabal on your path. But then I don't know if Nikola would need that modification done in any other place... you might try searching "Nikola pandoc on path" or something like that. Best of luck! – mechanical_meat Nov 24 '21 at 23:48

2 Answers2

3

pandoc is not a Python package. It is a separate and very powerful command line tool. nikola invokes the command line tool to do its work. You need to install it using the sudo apt install pandoc command line that they suggest.

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30
1

I discovered that the system was unable to find Pandoc as the entirety of the project was run in a Docker container; I had previously installed Pandoc on the system itself and failed. I was able to solve the problem by modifying the shell script to install Pandoc in the container.