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

Latex builder cannot download image URI #4720

Closed
drewejohnson opened this issue Mar 7, 2018 · 11 comments
Closed

Latex builder cannot download image URI #4720

drewejohnson opened this issue Mar 7, 2018 · 11 comments
Milestone

Comments

@drewejohnson
Copy link

Subject: Attemping to run make latex cannot download Travis badge

Problem

I am attempting to build an updated pdf for a project. Sphinx attempts to obtain the travis badge through, but fails. This causes the latex file to have a missing image, which breaks the pdf build.

Procedure to reproduce the problem

Nothing too fancy, just running make latex. Links to project and specific commit below

Error logs / results

$ make latex
Running Sphinx v1.7.1
building [mo]: targets for 0 po files that are out of date
building [latex]: all documents
looking for now-outdated files... none found
processing serpentTools.tex...index 
resolving references...
/home/ajohnson400/GitHub/serpent-tools/docs/welcome/about.rst:: WARNING: no matching candidate for image URI 'https://travis-ci.org/CORE-GATECH-GROUP/serpent-tools.svg?branch=master'
writing... done
copying TeX support files...
done
$ make -d latex
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Reading makefile 'Makefile'...
Updating makefiles....
 Considering target file 'Makefile'.
  File 'Makefile' does not exist.
  Finished prerequisites of target file 'Makefile'.
 Must remake target 'Makefile'.
 Successfully remade target file 'Makefile'.
Updating goal targets....
Considering target file 'latex'.
 File 'latex' does not exist.
 Looking for an implicit rule for 'latex'.
 Trying pattern rule with stem 'latex'.
 Trying rule prerequisite 'Makefile'.
 Found an implicit rule for 'latex'.
  Pruning file 'Makefile'.
 Finished prerequisites of target file 'latex'.
Must remake target 'latex'.
Putting child 0x13371e0 (latex) PID 13711 on the chain.
Live child 0x13371e0 (latex) PID 13711 
Running Sphinx v1.7.1
building [mo]: targets for 0 po files that are out of date
building [latex]: all documents
looking for now-outdated files... none found
processing serpentTools.tex...index 
resolving references...
/home/ajohnson400/GitHub/serpent-tools/docs/welcome/about.rst:: WARNING: no matching candidate for image URI 'https://travis-ci.org/CORE-GATECH-GROUP/serpent-tools.svg?branch=master'
writing... done
copying TeX support files...
done
Reaping winning child 0x13371e0 PID 13711 
Removing child 0x13371e0 PID 13711 from chain.
Successfully remade target file 'latex'.

Expected results

Download the badge such that the latex-pdf can be built.

Reproducible project / your project

Environment info

  • OS: Ubuntu 16.04
  • Python version: 3.5.2
  • Sphinx version: 1.7.1
  • tex: 3.14159265 TeX Live 2017
  • pdflatex: 3.14159265-2.6-1.40-18 TeX Live 2017
@cocoatomo
Copy link
Contributor

cocoatomo commented Mar 10, 2018

I could re-produce this issue.

Travis badge serpent-tools.svg has been downloaded actually, but latex builder ignore it
because vanilla LaTeX cannot treat .svg files (using \includegraphics command).
Instead Sphinx has sphinx.ext.imgconverter in order to convert .svg files into .png files that vanilla LaTeX can treat.

extensions = [
     'sphinx.ext.doctest',
     'sphinx.ext.coverage',
     'sphinx.ext.mathjax',
-    'sphinx.ext.napoleon']
+    'sphinx.ext.napoleon',
+    'sphinx.ext.imgconverter']
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']

After above patch was applied to conf.py, make latex ends successfully and cd _build/latex && make generates serpentTools.pdf.

/home/ajohnson400/GitHub/serpent-tools/docs/welcome/about.rst:: WARNING: no matching candidate for image URI 'https://travis-ci.org/CORE-GATECH-GROUP/serpent-tools.svg?branch=master'

This WARNING message is too confusing, because this issue is about configuration enabling Sphinx extension, not about candidates.
Therefore, desirable fix is appropriate log message.

@tk0miya
Copy link
Member

tk0miya commented Mar 10, 2018

Yes, LaTeX builder does not support SVG images. So you need to avoid the restriction by several ways.
sphinx.ext.imgconverter is one of them. We have other ways; only directive, image glob-ing, using PNG images (ex https://travis-ci.org/CORE-GATECH-GROUP/serpent-tools.png?branch=master) and so on.

Anyway, as @cocoatomo said, the warning message is not so good. I'll take a look it later.
Thanks,

@tk0miya tk0miya added this to the 1.7.2 milestone Mar 10, 2018
drewejohnson pushed a commit to CORE-GATECH-GROUP/serpent-tools that referenced this issue Mar 12, 2018
Recently encountered an issue where the sphinx latex builder
would not properly build, because the travis badge link was
downloaded as an svg and latex doesn't support svgs.

Following the advice on sphinx-doc/sphinx#4720, I used
a png image, but it didn't play well with the latex formatting.
So now the travis build badge is only included in html (web)
documentation.
@drewejohnson
Copy link
Author

Thank you very much for you help. I ended up using the only directive, and it worked like a dream

drewejohnson added a commit to CORE-GATECH-GROUP/serpent-tools that referenced this issue Mar 12, 2018
Recently encountered an issue where the sphinx latex builder
would not properly build, because the travis badge link was
downloaded as an svg and latex doesn't support svgs.

Following the advice on sphinx-doc/sphinx#4720, I used
a png image, but it didn't play well with the latex formatting.
So now the travis build badge is only included in html (web)
documentation.
tk0miya added a commit to tk0miya/sphinx that referenced this issue Mar 17, 2018
tk0miya added a commit to tk0miya/sphinx that referenced this issue Mar 17, 2018
tk0miya added a commit that referenced this issue Mar 18, 2018
…lobing

Fix #4720: message when an image is mismatched for builder is not clear
@tk0miya
Copy link
Member

tk0miya commented Mar 18, 2018

The message was updated by #4748. Closing.

@tk0miya tk0miya closed this as completed Mar 18, 2018
@tk0miya
Copy link
Member

tk0miya commented Mar 18, 2018

Thank you for reporting!

@ale5000-git
Copy link

Hi,
I thought that simpy adding "sphinx.ext.imgconverter" to conf.py fixed the problem of pdf build but it isn't like this.

Can someone please expain simply how to auto convert all svg images?

@tk0miya
Copy link
Member

tk0miya commented May 1, 2018

@ale5000-git I'm not a ESPer. Please let me know your situation. What version did you use? How did you configure?
Please post your situation to sphinx-users list.

Thanks,

@ale5000-git
Copy link

ale5000-git commented May 3, 2018

@tk0miya
I'm not using this directly but from readthedocs.org.

The source of the documentation is here.
The result is here.

The log from the site:

Running Sphinx v1.7.4

loading translations [en]... done
making output directory...
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [latex]: all documents
updating environment: 4 added, 0 changed, 0 removed
reading sources... [ 25%] LICENSE.LESSER
reading sources... [ 50%] api
reading sources... [ 75%] index
reading sources... [100%] intro

../LICENSE.rst:11: WARNING: Title level inconsistent:

PREAMBLE
========
../LICENSE.rst:75: WARNING: Title level inconsistent:

TERMS AND CONDITIONS
====================
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
processing PyCompatLayer.tex...index intro api LICENSE.LESSER 
resolving references...
WARNING: convert command 'convert' cannot be run.check the image_converter setting
../README.rst:: WARNING: a suitable image for latex builder not found: ['image/svg+xml'] (https://img.shields.io/bountysource/team/pycompatlayer/activity.svg?maxAge=3600)
../README.rst:: WARNING: a suitable image for latex builder not found: ['image/svg+xml'] (https://travis-ci.org/ale5000-git/pycompatlayer.svg?branch=master)
../README.rst:: WARNING: a suitable image for latex builder not found: ['image/svg+xml'] (https://codecov.io/gh/ale5000-git/pycompatlayer/branch/master/graph/badge.svg)
../README.rst:: WARNING: a suitable image for latex builder not found: ['image/svg+xml'] (https://img.shields.io/pypi/v/PyCompatLayer.svg?maxAge=3600)
../README.rst:: WARNING: a suitable image for latex builder not found: ['image/svg+xml'] (https://img.shields.io/github/release/ale5000-git/pycompatlayer.svg?label=github&maxAge=3600)
../README.rst:: WARNING: a suitable image for latex builder not found: ['image/svg+xml'] (https://img.shields.io/github/downloads/ale5000-git/pycompatlayer/total.svg?label=github%20downloads&maxAge=3600)
../README.rst:: WARNING: a suitable image for latex builder not found: ['image/svg+xml'] (https://img.shields.io/pypi/pyversions/PyCompatLayer.svg?maxAge=3600)
../README.rst:: WARNING: a suitable image for latex builder not found: ['image/svg+xml'] (https://api.codacy.com/project/badge/Grade/38c8566189bc44eb91532e3004236c57)
../README.rst:: WARNING: a suitable image for latex builder not found: ['image/svg+xml'] (https://codebeat.co/badges/ab05b70b-9386-4696-a89d-dcacab208284)
../README.rst:: WARNING: a suitable image for latex builder not found: ['image/svg+xml'] (https://codeclimate.com/github/ale5000-git/pycompatlayer/badges/gpa.svg)
writing... done
copying TeX support files...
done
build succeeded, 13 warnings.

The LaTeX files are in _build/latex.
Run 'make' in that directory to run these through (pdf)latex
(use `make latexpdf' here to do that automatically).

@tk0miya
Copy link
Member

tk0miya commented May 7, 2018

WARNING: convert command 'convert' cannot be run.check the image_converter setting

It seems readthedocs.org does not provide imagemagick. So sphinx.ext.imgconverter will not work.
I don't know how to enable it on readthedocs. Please ask to the administrator.

Anyway, this is not a forum. This is an issue list for Sphinx.
Please post to sphinx-users list in next time.
https://groups.google.com/forum/#!forum/sphinx-users

Thanks,

smirolo added a commit to djaodjin/djaodjin-saas that referenced this issue Sep 14, 2019
Read-the-docs generates the following log on builds

    WARNING: a suitable image for latex builder not found: ['image/svg+xml']

    Exception occurred:
        mimetypes = sorted(node['candidates'])
    TypeError: '<' not supported between instances of 'str' and 'NoneType'

Looking at sphinx/builders/__init__.py, the exception seems image related.
An potential fix is suggested in
sphinx-doc/sphinx#4720 (comment)
@Borda
Copy link

Borda commented Dec 10, 2019

I try to use the sphinx.ext.imgconverter because I have some badges in the readme (URI/SVG images) but it crashes...

Extension error:
convert exited with error:
[stderr]
b"convert-im6.q16: delegate failed `'rsvg-convert' -o '%o' '%i'' @ error/delegate.c/InvokeDelegate/1919.\nconvert-im6.q16: unable to open file `/tmp/magick-12213u671hXtMTiQL': No such file or directory @ error/constitute.c/ReadImage/544.\nconvert-im6.q16: no images defined `/home/jb/Dropbox/Workspace/BIRL/docs/build/doctrees/images/BIRL.png' @ error/convert.c/ConvertImageCommand/3258.\n"
[stdout]
b''

@tk0miya
Copy link
Member

tk0miya commented Dec 10, 2019

@Borda Could you file a new issue please? This was already closed.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants