Skip to content

The example fails to build on Linux: latexrun IndexError #56

@dwtj

Description

@dwtj

When I attempt to run bazel build //example/... on my Linux system (specifically, Fedora 34 and Bazel v4.0.0), I consistently get an error like the following:

ERROR: /home/dwtj/Projects/bazel-latex/example/BUILD.bazel:3:15: LuaLatex example/my_report.pdf failed: (Exit 1): run_lualatex failed: error executing command bazel-out/host/bin/run_lualatex external/texlive_bin__x86_64-linux/kpsewhich external/texlive_bin__x86_64-linux/luatex external/texlive_bin__x86_64-linux/bibtex external/texlive_bin__x86_64-linux/biber ... (remaining 6 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox run_lualatex failed: error executing command bazel-out/host/bin/run_lualatex external/texlive_bin__x86_64-linux/kpsewhich external/texlive_bin__x86_64-linux/luatex external/texlive_bin__x86_64-linux/bibtex external/texlive_bin__x86_64-linux/biber ... (remaining 6 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
Traceback (most recent call last):
  File "/home/dwtj/.cache/bazel/_bazel_dwtj/01719a99d816f1177918d0383df58452/sandbox/linux-sandbox/18/execroot/bazel_latex/external/bazel_latex_latexrun/latexrun", line 1982, in <module>
    main()
  File "/home/dwtj/.cache/bazel/_bazel_dwtj/01719a99d816f1S177918d0383df58452/sandbox/linux-sandbox/18/execroot/bazel_latex/external/bazel_latex_latexrun/latexrun", line 169, in main
    stable = run_tasks(tasks, args.max_iterations)
  File "/home/dwtj/.cache/bazel/_bazel_dwtj/01719a99d816f1177918d0383df58452/sandbox/linux-sandbox/18/execroot/bazel_latex/external/bazel_latex_latexrun/latexrun", line 558, in run_tasks
    task.run()
  File "/home/dwtj/.cache/bazel/_bazel_dwtj/01719a99d816f1177918d0383df58452/sandbox/linux-sandbox/18/execroot/bazel_latex/external/bazel_latex_latexrun/latexrun", line 655, in run
    result = self._execute()
  File "/home/dwtj/.cache/bazel/_bazel_dwtj/01719a99d816f1177918d0383df58452/sandbox/linux-sandbox/18/execroot/bazel_latex/external/bazel_latex_latexrun/latexrun", line 1657, in _execute
    inputs, auxnames, outbase = self.__parse_inputs(stdout, cwd, env)
  File "/home/dwtj/.cache/bazel/_bazel_dwtj/01719a99d816f1177918d0383df58452/sandbox/linux-sandbox/18/execroot/bazel_latex/external/bazel_latex_latexrun/latexrun", line 1751, in __parse_inputs
    outbase = auxnames[0][:-4]
IndexError: list index out of range
----------------
Note: The failure of target //:run_lualatex (with exit code 1) may have been caused by the fact that it is running under Python 3 instead of Python 2. Examine the error to determine if that appears to be the problem. Since this target is built in the host configuration, the only way to change its version is to set --host_force_python=PY2, which affects the entire build.

If this error started occurring in Bazel 0.27 and later, it may be because the Python toolchain now enforces that targets analyzed as PY2 and PY3 run under a Python 2 and Python 3 interpreter, respectively. See https://github.com/bazelbuild/bazel/issues/7899 for more information.
----------------

However, I do not get this error when I build the project on my macOS machine (specifically, macOS 11.3.1 and Bazel 4.0.0).

Clearly, the error is coming from the latexrun script's __parse_inputs() function. The cause is that this expression indexes into the empty list.

(Note: the hint about Python 2/3 seems to be a false lead, since Linux fails regardless of Python version and macOS succeeds regardless of version.)

By adding an additional latexrun patch, I found that when __parse_inputs() is run:

  • outbase is set to None on Linux
  • outbase is set to "my_report" on macOS.

Thus, on macOS, the offending line of code isn't being hit. So no error, and the build succeeds.

My hunch is that this problem might arise from differences between Bazel's sandboxing strategies on these two platforms. But just using the Bazel option --spawn_strategy=local doesn't fix anything, so maybe not.

I know next to nothing about LaTeX compilation, so I'll leave it to others to further diagnose the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions