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

Action fails with due to missing log file #5

Closed
cmouse opened this issue Dec 20, 2019 · 22 comments
Closed

Action fails with due to missing log file #5

cmouse opened this issue Dec 20, 2019 · 22 comments

Comments

@cmouse
Copy link

cmouse commented Dec 20, 2019

Version: 0.1

https://github.com/cmouse/dovecot-documentation/commit/95de65dc80bf4cf3ddbf57a3f0e1fc0c6fab4f9a/checks?check_suite_id=368217245

The build fails because it cannot find some sphinx log file. There is no indication anywhere how it should be created?

@ammaraskar
Copy link
Owner

Sorry for the late reply. Would you mind giving the latest version a shot? The sphinx log is needed to parse the errors and if the docs build successfully (which they seem like they do in your logs), then it should exist.

@ocket8888
Copy link

I'm pinned to action version @master and have the same issue:

====================================
Building docs in docs/
====================================
Traceback (most recent call last):
  File "/entrypoint.py", line 27, in <module>
    action.build_all_docs(github_env, [os.environ.get('INPUT_DOCS-FOLDER')])
  File "/sphinx_action/action.py", line 137, in build_all_docs
    return_code, annotations = build_docs(
  File "/sphinx_action/action.py", line 112, in build_docs
    with open(log_file, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/sphinx-log'

@cmouse
Copy link
Author

cmouse commented Dec 25, 2019

Sorry for the late reply. Would you mind giving the latest version a shot? The sphinx log is needed to parse the errors and if the docs build successfully (which they seem like they do in your logs), then it should exist.

Sorry for not replying, I can try this again after next week.

@Enderdead
Copy link

I've figured out the problem. The issue is due to a problem with argument passing. When you use the default build cmd (make), the build call is this one :

if build_command[0] == 'make':
return_code = subprocess.call(
build_command,
env=dict(os.environ, SPHINXOPTS=sphinx_options),
cwd=docs_directory
)

In this manner, you pass the -w '/tmp/sphinx-log' argument as an env var.
But in general, your make file looks like this :

SPHINXOPTS    =
SPHINXBUILD   = sphinx-build
SOURCEDIR     = source
BUILDDIR      = build

# Put it first so that "make" without argument is like "make help".
help:
	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

This script doesn't take into account your env var so the log file won't be generated.

An easy way to fix that is to use a custom build cmd like this one: build-command: "sphinx-build source build".

Because in this case, the action script will execute this line.

return_code = subprocess.call(
build_command + shlex.split(sphinx_options),
cwd=docs_directory
)

Sphinx option will be hard written in the command.

@ocket8888
Copy link

If I'm understanding this right another solution is to replace our current sphinx options e.g. SPHINXOPTS = --foo with an additive assignment like SPHINXOPTS += --foo

@Enderdead
Copy link

I've just tested your solution and it works! Just add a plus before the equals like this :

SPHINXOPTS    +=

That doesn't matter if the right side is empty.

@cmouse
Copy link
Author

cmouse commented Dec 30, 2019

If I'm understanding this right another solution is to replace our current sphinx options e.g. SPHINXOPTS = --foo with an additive assignment like SPHINXOPTS += --foo

Wonder if this should be upstreamed?

@novski
Copy link

novski commented Jan 4, 2020

Tested, and can confirm the additive assignment worked in my case as well.
Got to your YOUR-GITHUB-USER/REPO-NAME/docs/Makefile and change Line 5 to SPHINXOPTS += like in my case.

iguessthislldo added a commit to OpenDDS/pyopendds that referenced this issue Feb 15, 2020
@iguessthislldo
Copy link

Wonder if this should be upstreamed?

If not I think the README should at least make note of it.

@ammaraskar
Copy link
Owner

Apologies for the late response, thanks for investigating this everyone.

If you take a look at my test projects here:

# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

They seem to be setup so that they support overriding through environment variables. Maybe this is a change in newer version of sphinx. The intention with this project was to just have it be drop-in without having the user make any changes to their sphinx stuff, let me see if I can find a more versatile way to achieve this.

@ammaraskar
Copy link
Owner

Could someone try with the origin Makefile and the action pinned to master? I think this commit should help:

1983868

@Enderdead
Copy link

Tested on my own project. Everything looks fine. Good job!
You can review this at this repo: https://github.com/Enderdead/pyLambdaFlows/tree/TestSphinxAction

@ammaraskar
Copy link
Owner

Feel free to re-open if anyone finds the latest release doesn't work with their original Makefiles.

@Narayana-Rao
Copy link

Narayana-Rao commented Dec 31, 2020

Facing the log file issue with both original and updated make file.

====================================
Building docs in help/

[sphinx-action] Running: ['sphinx-build', '-b', 'html', '--keep-going', '--no-color', '-w', '/tmp/sphinx-log']
action.build_all_docs(github_env, [os.environ.get("INPUT_DOCS-FOLDER")])
File "/sphinx_action/action.py", line 152, in build_all_docs
return_code, annotations = build_docs(github_env.build_command, docs_dir)
File "/sphinx_action/action.py", line 134, in build_docs
with open(log_file, "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/sphinx-log'

here is my code:

name: Docs Check on Push

on: [push]

jobs:
build:

  runs-on: ubuntu-latest

  steps:
  - uses: actions/checkout@v2
  # Standard drop-in approach that should work for most people.
  - uses: ammaraskar/[email protected]
    with:
      pre-build-command: python -m pip install -r help/requirements.txt
      docs-folder: "help/"
  # Example of using a custom build-command.
  - uses: ammaraskar/[email protected]
    with:
      build-command: "sphinx-build -b html"
      docs-folder: "help/"

@ammaraskar
Copy link
Owner

Your build is failing for a different reason:

usage: sphinx-build [OPTIONS] SOURCEDIR OUTPUTDIR [FILENAMES...]
sphinx-build: error: the following arguments are required: sourcedir, outputdir, filenames

The build command doesn't have a source folder specified as you can see from the "Running:" line. Your build-command should look instead like sphinx-build . -b html, notice the dot representing the current directory.

@Narayana-Rao
Copy link

Narayana-Rao commented Jan 1, 2021

Thank you. But, still the same error
could you please help?
Here is my docs folder
https://github.com/Narayana-Rao/SAR-tools/tree/master/help

====================================
Building docs in help/

[sphinx-action] Running: ['sphinx-build', '.', '-b', 'html', '--keep-going', '--no-color', '-w', '/tmp/sphinx-log']
with open(log_file, "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/sphinx-log'

cameronraysmith added a commit to cameronraysmith/nbsphinx-template that referenced this issue May 27, 2021
zehsilva added a commit to clarify/pyclarify that referenced this issue Sep 16, 2021
zehsilva added a commit to clarify/pyclarify that referenced this issue Sep 16, 2021
zehsilva added a commit to clarify/pyclarify that referenced this issue Sep 16, 2021
zehsilva added a commit to clarify/pyclarify that referenced this issue Sep 16, 2021
zehsilva added a commit to clarify/pyclarify that referenced this issue Sep 16, 2021
zehsilva added a commit to clarify/pyclarify that referenced this issue Sep 16, 2021
zehsilva added a commit to clarify/pyclarify that referenced this issue Sep 16, 2021
@DominiqueMakowski
Copy link

DominiqueMakowski commented Apr 20, 2022

Hi, I am still encountering the same issue:

Traceback (most recent call last):
  File "/entrypoint.py", line 22, in <module>
    action.build_all_docs(github_env, [os.environ.get("INPUT_DOCS-FOLDER")])
  File "/sphinx_action/action.py", line 152, in build_all_docs
    return_code, annotations = build_docs(github_env.build_command, docs_dir)
  File "/sphinx_action/action.py", line 134, in build_docs
    with open(log_file, "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/sphinx-log'

when building the documentation using the action and this command:

sphinx-build -b html . _build

Note that at the end of the log it says:

[sphinx-action] Running: ['sphinx-build', '-b', 'html', '.', '_build', '--keep-going', '--no-color', '-w', '/tmp/sphinx-log']

How can I modify the last argument?

@ocket8888
Copy link

Looks like your build command is missing the -w /tmp/sphinx-log argument

@pmilano1
Copy link

pmilano1 commented Jun 2, 2022

Anyone still getting this? I'm using this for workflow -

name: "Generate Documentation"
on:
- push

jobs:
  docs:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: ammaraskar/sphinx-action@master
      with:
        build-command: "sphinx-build -b html docsrc/ _build -f /tmp/sphinx.log "
        docs-folder: "docs/"

and Makefile

# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS    =
SPHINXBUILD   = sphinx-build
SOURCEDIR     = .
BUILDDIR      = build

# Put it first so that "make" without argument is like "make help".
help:
	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

and still get

====================================
Building docs in docs/
====================================
[sphinx-action] Running: ['sphinx-build', '-b', 'html', 'docsrc/', '_build', '-f', '/tmp/sphinx.log', '--keep-going', '--no-color', '-w', '/tmp/sphinx-log']
Traceback (most recent call last):
  File "/entrypoint.py", line 22, in <module>
    action.build_all_docs(github_env, [os.environ.get("INPUT_DOCS-FOLDER")])
  File "/sphinx_action/action.py", line 152, in build_all_docs
    return_code, annotations = build_docs(github_env.build_command, docs_dir)
  File "/sphinx_action/action.py", line [13](https://github.com/myorg/myrepo/runs/6717418890?check_suite_focus=true#step:4:14)4, in build_docs
    with open(log_file, "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/sphinx-log'

@ocket8888
Copy link

Your Makefile seems irrelevant, it doesn't look to be using that.

The output of the runner shows a different build command than the one you specified. Are you sure that it's using the configuration you posted? You also seem to be using -f /tmp/sphinx-log instead of/in addition to -w /tmp/sphinx-log.

At any rate, this issue is about builders that use make, so your problem is probably unrelated.

eloyvallinaes added a commit to eloyvallinaes/sphinx that referenced this issue Jul 26, 2022
Version 0.4 of sphinx-action contains a problem investigated and documented here: ammaraskar/sphinx-action#5. The action throws an error claiming it can't write the log file. The problem is fixed in master and since this is a tutorial, it is more or less expected that it should work off the bat, so I thinking pinning the master version for now and the next release when it comes out, might be the best way to help newbies.
robsdedude pushed a commit to robsdedude/sphinx that referenced this issue Jul 29, 2022
Version 0.4 of sphinx-action contains a problem investigated and documented here: ammaraskar/sphinx-action#5. The action throws an error claiming it can't write the log file. The problem is fixed in master and since this is a tutorial, it is more or less expected that it should work off the bat, so I thinking pinning the master version for now and the next release when it comes out, might be the best way to help newbies.
@Claudio9701
Copy link

I was having the same missing log file error, none of the above worked. The solution was to add this lines to my docs/requirements.txt

sphinx>=6.1.3
docutils>=0.19

@SoundsSerious
Copy link

@Claudio9701 +1 for this

mbarbin added a commit to mbarbin/doc-experiment-sphinx that referenced this issue Mar 30, 2023
The following flags are added to the command:

    '-w', '/tmp/sphinx-log'

This is causing the following issue:

    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/sphinx-log'

This may be related to this issue:

    ammaraskar/sphinx-action#5

Attempted to fix this by forcing the upgrade of sphinx and docutils.
Possibly the issue comes from the way older version would behave when
passed -w. TBD.
mhendrey added a commit to mhendrey/vekterdb that referenced this issue Jan 19, 2024
Trying to debug failed sphinx workflow action.

ammaraskar/sphinx-action#5 (comment)
mhendrey added a commit to mhendrey/vekterdb that referenced this issue Jan 19, 2024
RyanDoesMath pushed a commit to Paper-Chart-Extraction-Project/ChartExtractor that referenced this issue May 31, 2024
The GitHub action that was intended to publish the documentation failed because `FileNotFoundError: [Errno 2] No such file or directory: '/tmp/sphinx-log'`

This issue claims the solution is to change one character in the make file: ammaraskar/sphinx-action#5
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