I have a repository that has a LaTex file inside a folder. The folder is named Literature Review
and the file is named Review.tex
. I’m new to docker and GitHub Actions. I have tried a lot of different combinations to set the file path:
Literature Review/Review.tex
I have tried a lot of methods suggested on StackOverflow but it seems I’m too naive to understand the implementation correctly xD
I read somewhere that to avoid an escape sequence, we can use a before the space. This, however, did not make much difference.
The workflow returns the following error while building:
Run echo ${MANUSCRIPT_PATH}.tex
echo ${MANUSCRIPT_PATH}.tex
${LATEX} ${MANUSCRIPT_PATH}.tex
${BIBTEX} ${MANUSCRIPT_PATH}.aux
${LATEX} ${MANUSCRIPT_PATH}.tex
${LATEX} ${MANUSCRIPT_PATH}.tex
shell: /bin/bash -e {0}
env:
MANUSCRIPT_PATH: Literature Review/Review
LATEX: pdflatex -shell-escape
BIBTEX: bibtex
Literature Review/Review.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=pdflatex)
write18 enabled.
entering extended mode
! I can't find file `Literature'.
<to be read again>
<*> Literature
Review/Review.tex
(Press Enter to retry, or Control-D to exit)
Please type another input file name:
! Emergency stop.
<to be read again>
<*> Literature
Review/Review.tex
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on texput.log.
Error: Process completed with exit code 1.
My yml
file looks like this:
name: paper-maker
on: push
jobs:
build:
runs-on: ubuntu-latest
env:
# This needs fixing
MANUSCRIPT_PATH: 'Literature Review/Review' # exclude the '.tex' / '.pdf' extension!
LATEX: pdflatex -shell-escape
BIBTEX: bibtex
steps:
- uses: actions/checkout@v1
- name: Install texlive
run: |
sudo apt-get install texlive-publishers
texlive-latex-recommended
texlive-latex-extra
texlive-fonts-recommended
texlive-fonts-extra
- name: Build paper
run: |
echo ${MANUSCRIPT_PATH}.tex
${LATEX} ${MANUSCRIPT_PATH}.tex
${BIBTEX} ${MANUSCRIPT_PATH}.aux
${LATEX} ${MANUSCRIPT_PATH}.tex
${LATEX} ${MANUSCRIPT_PATH}.tex
- name: Push paper
run: |
git checkout --orphan ${GITHUB_REF##*/}-pdf
git rm -rf .github/
git rm -rf .
git add -f ${MANUSCRIPT_PATH##*/}.pdf
git -c user.name='paper-maker' -c user.email='paper-maker' commit -m "update pdf"
git push -q -f https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} ${GITHUB_REF##*/}-pdf
2
Answers
Don’t try to individually escape space characters, just put the resulting path in double quotes:
It seems that backslash-escapes are processed before variable substitution, which is why your approach doesn’t work.
In any case, putting the final path in double quotes is long-established best practice.
Edit: To elaborate a bit, this has nothing to do with Docker or YAML. Just try this piece of code in bash:
You will get
As you can see, the backslash is not escaping the following space in variable substitution. Instead, the shell acts like you gave the two parameters
'a'
and'b/c.txt'
.Use double quotation marks inside of the single quotation marks like this:
'"Literature Review/Review"'
. Parsing the YAML removes the single quotation marks and the value of your environment variable will be"Literature Review/Review"
. This in turn will make pdflatex receiveLiterature Review/Review
as a single argument.