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

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

Open
dwtj opened this issue May 19, 2021 · 4 comments
Open

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

dwtj opened this issue May 19, 2021 · 4 comments

Comments

@dwtj
Copy link

dwtj commented May 19, 2021

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.

@Kernald
Copy link
Collaborator

Kernald commented Oct 20, 2022

Interestingly enough, we hit the same error on GitHub Actions when running on ubuntu-latest - see #93. I didn't reproduce it locally with Ubuntu 20.04 (used by ubuntu-latest), but I'll give Fedora 34 a try - reproducing locally would help a lot with diagnosing what's going on.

@Kernald
Copy link
Collaborator

Kernald commented Oct 22, 2022

Reproduced with a Fedora 34 VM. I'll try to figure out what's going on over the next few days.

@solsjo
Copy link
Collaborator

solsjo commented Feb 28, 2023

ubuntu-latest is now at ubuntu-22.04. The rules seems to function there.
The rules have been refactored quite a bit lately. But it might make sense to add both ubuntu-18.04 and ubuntu-20.04 to the matrix so that we notice blindspots like these.

@solsjo
Copy link
Collaborator

solsjo commented Mar 16, 2023

@dwtj would you mind, checking out latest master and checking if the problem still exist. I assume it will. I just want the confirmation. If I’m going to start looking into it.

Kind regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants