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

Knit RMarkdown to PDF not working #82

Open
DuGamla opened this issue Nov 13, 2018 · 14 comments
Open

Knit RMarkdown to PDF not working #82

DuGamla opened this issue Nov 13, 2018 · 14 comments

Comments

@DuGamla
Copy link

DuGamla commented Nov 13, 2018

Hi yihui,

i have an issue with knit rmarkdown to pdf in RStudio. I am using TinyTex and try to knit following rmarkdown example:

---
title: "Untitled"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
plot(pressure)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

Selection of "Knit to PDF" provides :

  |.........                                                        |  14%
  ordinary text without R code

  |...................                                              |  29%
label: setup (with options) 
List of 1
 $ include: logi FALSE



processing file: Test.Rmd
  |............................                                     |  43%
  ordinary text without R code

  |.....................................                            |  57%
label: cars
  |..............................................                   |  71%
  ordinary text without R code

  |........................................................         |  86%
label: pressure (with options) 
List of 1
 $ echo: logi FALSE

  |.................................................................| 100%
  ordinary text without R code


"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS Test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output Test.tex --template "C:\Users\v005194\Documents\R\win-library\3.5\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" --variable "compact-title:yes" 
output file: Test.knit.md

tlmgr search --file --global "/xcolor.sty"
Trying to automatically install missing LaTeX packages...
tlmgr install xcolor
No connection to the internet.
Unable to download the checksum of the remote TeX Live database,
but found a local copy so using that.

You may want to try specifying an explicit or different CTAN mirror;
see the information and examples for the -repository option at
http://tug.org/texlive/doc/install-tl.html
(or in the output of install-tl --help).

tlmgr.pl: package repository http://ctan.math.washington.edu/tex-archive/systems/texlive/tlnet (not verified: unknown)
[1/1, ??:??/??:??] install: xcolor [17k]
TLPDB::_install_package: downloading did not succeed
tlmgr.pl: package log updated: C:/Users/v005194/AppData/Roaming/TinyTeX/texmf-var/web2c/tlmgr.log
tlmgr search --file --global "/xcolor.sty"
! LaTeX Error: File `xcolor.sty' not found.

! Emergency stop.
<read *> 

Fehler: Failed to compile Test.tex. See Test.log for more info.
Ausführung angehalten

I am not using the xcolor-package anywhere... What can i do to fix that problem? I am an simple user on my work-computer (not an admin).
I see a possible solution at ur website https://yihui.name/en/2018/08/tinytex-flash-drive/. But I am not able to use Dropbox on my computer.

By the way: I started this thread at https://tex.stackexchange.com/questions/459113/problem-with-knit-r-markdown-to-pdf too.

@yihui
Copy link
Member

yihui commented Nov 13, 2018

Interesting. If you don't have the internet connection, how did you install TinyTeX? Are you behind a proxy like #81?

@DuGamla
Copy link
Author

DuGamla commented Nov 13, 2018

Yes, i have the same problem like #81, but i am not allowed to use a flashdrive.

@yihui
Copy link
Member

yihui commented Nov 13, 2018

So your sysadmin/IT installed TinyTeX for you?

@DuGamla
Copy link
Author

DuGamla commented Nov 13, 2018

No, i installed TinyTeX. I used tinytex::install_tinytex(), but this provides tinytex:::is_tinytex() <- False.
Then i used tinytex:::install_prebuilt(), and got tinytex:::is_tinytex() <- True.

@DuGamla
Copy link
Author

DuGamla commented Nov 14, 2018

Ok, i solve the problem:
At the path C:\Users\v005194\AppData\Roaming\TinyTeX\texmf-dist\tex\latex\fancyvrb the fancyber.sty file used xcolor. I delete that file and add the files hcolor.sty, fancyvrb.sty (another which do not use xcolor), fvrb-ex.sty and hbaw.sty.

And now it is working...

@DuGamla
Copy link
Author

DuGamla commented Nov 14, 2018

... but i would like to use the xcolor package on my working-computer. How can i do it without admin-rights?

If i use the xcolor package at my header-includes i get the same problem as stated above. Do u know any possibility without flashdrive yihui?

@GitHubRulesOK
Copy link

GitHubRulesOK commented Nov 16, 2018

@yihui Sorry to butt in but I suggested @DuGamla open an issue to try to resolve his problem, I tried testing AS Standard User (NOT admin NO proxy) I use portable R (should not be different in this case ?)
My experience
I run R-Studio it asks for Tex I type in > tinytex::install_tinytex()
Starting to install TinyTeX to C:\Users\Standard User\AppData\Roaming/TinyTeX.
I see Please restart your R session and IDE
I ignore just to see if there is an issue
I knit to pdf processing file: test.Rmd and see
tlmgr search --file --global "/xcolor.sty"
Trying to automatically install missing LaTeX packages...
tlmgr install xcolor
I wait and see

tlmgr.pl: package repository http://anorien.csc.warwick.ac.uk/mirrors/CTAN/systems/texlive/tlnet (not verified: gpg unavailable)
[1/1, ??:??/??:??] install: xcolor [17k]
running mktexlsr ...
done running mktexlsr.
tlmgr.pl: package log updated: C:/Users/Standard User/AppData/Roaming/TinyTeX/texmf-var/web2c/tlmgr.log
Output created: test.pdf

So I DO NOT have a problem, what is the key difference (I DO know I don't have a proxy)

Questions
Do you have any suggestions how to TEST for proxy user issues
BEST WAY to update Tiny Packages on the fly on a default user drive ?

so for example if user sees they need xcolor
what steps to download unpack and register in FNDB etc.

@yihui
Copy link
Member

yihui commented Nov 16, 2018

@GitHubRulesOK For users behind the proxy, it is possible to make TinyTeX work. It depends on if the proxy server can be accessed via a standard form like http://your.proxy.example.com:8080/. If it can, see #81 (comment) for how to set up the proxy for TinyTeX (essentially for wget).

@GitHubRulesOK
Copy link

GitHubRulesOK commented Nov 17, 2018

Thanks I was aware of that (and that it could be added to update scripts environment if known)
But messing about with basic users is likely to upset the IT department that caused the issue !

So simple users need a very simple test to confirm it is a proxy firewalling their attempt to update
In the past they could then be told to look in explorer to copy the details, not sure about win10 as edge may not show the company logon script settings

I don't understand which protocol the initial install is used by R studio call (which seems to work for all users) but is NOT available for the tex wget to update without jumping through extra hoops

I am not sure if there are any user right problems with %appdir% however since IT department gave the user right to the R studio directories could we benefit from moving Tiny Tex there as a subfolder?

You say wget is using http does rstudio command tinytex::install_tinytex() use ftp ? I don't understand why there may be a proxy difference between tinytex:::install and TLmgr update ?

I don't want to go down the route of unpackaging ctan files to texmf, I would like to just tell them where the latest package that Tiny Tex calls can be downloaded and where to add to users TinyTex folder (as if it had been fetched) so it can be installed by simply running recompile

For a few packages it is possibly the easiest solution rather than upset the company IT guys. (if it is a larger number then best to have IT department involved, that's is what they are paid for)

@GitHubRulesOK
Copy link

I guess what i'm looking for is something that expands the install to include xcolor like this how does the extra packages work ?

tinytex::reinstall_tinytex(packages = TRUE, dir = tinytex_root(), repository = "ctan", extra_packages = xcolor)

@rainer-rq-koelle
Copy link

For others coming to this thread.

It might take a while, but the problem can be fixed with running the package update install by hand (and hoping that it is only a manageable number of packages). You have to knit the file several times to work through all the missing packages.

I ran into a similar issue as reported by @DuGamla above. I work on a windows X laptop. When knitting the Rmd file to pdf, I ended up with

tlmgr.pl: package repository http://ctan.math.illinois.edu/systems/texlive/tlnet (not verified: unknown)
[1/1, ??:??/??:??] install: xcolor [17k]
TLPDB::_install_package: downloading did not succeed (download_file failed)
tlmgr.pl: package log updated: C:/<<my-path-redacted>>/TinyTeX/texmf-var/web2c/tlmgr.log
tlmgr search --file --global "/xcolor.sty"
! LaTeX Error: File `xcolor.sty' not found.

! Emergency stop.

Going back to the R console, I could launch

tinytex::tlmgr_install("xcolor")

which ran nicely echoing the following:

tlmgr install xcolor
tlmgr.pl: package repository http://ctan.math.illinois.edu/systems/texlive/tlnet (not verified: gpg unavailable)
[1/1, ??:??/??:??] install: xcolor [17k]
 running mktexlsr ...
 done running mktexlsr.
 tlmgr.pl: package log updated: C:/<<my-path-redacted>>/TinyTeX/texmf-var/web2c/tlmgr.log

I had to do this for the following packages (xcolor, multirow, wrapfig, colortbl, pdflscape, tabu, varwidth, threeparttable, threeparttablex, environ, trimspaces, ulem, makecell, epstopdf-pkg).

I know too little about how this all works, however, I have the feeling that the attempt to install the packages automatically might have a typo in the repo address or something like this.
As I have been able to install the packages by hand (without supplying another repo dir), the issue should be in the download address automatically generated.

In my case installing the missing packages by hand was ok, although I would have loved to be able to avoid the tedious process: (i) knit --> check error for missing package (ii) install by hand and go back to (i).
Is there a way to find out what packages are missing and possibly downloading them in one go?

@rccline
Copy link

rccline commented Dec 26, 2019

Still no joy: Unable to install tlper.win32

tlmgr.pl: Fundamental package tlperl.win32 not present, uh oh, goodbyeShould not happen, tlperl.win32 not found at C:\Users\Robert\AppData\Roaming\TinyTeX\texmf-dist\scripts\texlive\tlmgr.pl line 7439.
tlmgr.pl: package repository http://ctan.math.washington.edu/tex-archive/systems/texlive/tlnet (not verified: gpg unavailable)

@rlm8109
Copy link

rlm8109 commented Feb 10, 2022

For others coming to this thread.

It might take a while, but the problem can be fixed with running the package update install by hand (and hoping that it is only a manageable number of packages). You have to knit the file several times to work through all the missing packages.

I ran into a similar issue as reported by @DuGamla above. I work on a windows X laptop. When knitting the Rmd file to pdf, I ended up with

tlmgr.pl: package repository http://ctan.math.illinois.edu/systems/texlive/tlnet (not verified: unknown)
[1/1, ??:??/??:??] install: xcolor [17k]
TLPDB::_install_package: downloading did not succeed (download_file failed)
tlmgr.pl: package log updated: C:/<<my-path-redacted>>/TinyTeX/texmf-var/web2c/tlmgr.log
tlmgr search --file --global "/xcolor.sty"
! LaTeX Error: File `xcolor.sty' not found.

! Emergency stop.

Going back to the R console, I could launch

tinytex::tlmgr_install("xcolor")

which ran nicely echoing the following:

tlmgr install xcolor
tlmgr.pl: package repository http://ctan.math.illinois.edu/systems/texlive/tlnet (not verified: gpg unavailable)
[1/1, ??:??/??:??] install: xcolor [17k]
 running mktexlsr ...
 done running mktexlsr.
 tlmgr.pl: package log updated: C:/<<my-path-redacted>>/TinyTeX/texmf-var/web2c/tlmgr.log

I had to do this for the following packages (xcolor, multirow, wrapfig, colortbl, pdflscape, tabu, varwidth, threeparttable, threeparttablex, environ, trimspaces, ulem, makecell, epstopdf-pkg).

I know too little about how this all works, however, I have the feeling that the attempt to install the packages automatically might have a typo in the repo address or something like this. As I have been able to install the packages by hand (without supplying another repo dir), the issue should be in the download address automatically generated.

In my case installing the missing packages by hand was ok, although I would have loved to be able to avoid the tedious process: (i) knit --> check error for missing package (ii) install by hand and go back to (i). Is there a way to find out what packages are missing and possibly downloading them in one go?

Thanks! Was running OS X Monterey 12.2 and R 4.1.2 plus the latest version of R Studio with all other packages up to date, thinking everything would simply be fine, and then this cropped up. A project that would ordinarily knit to PDF quickly started to take hours to knit, then it kept throwing back these errors, each time citing a seemingly random .sty file. Spent days looking for a fix, trying everything out there and nothing worked until the above.

But as painful as it was (having to knit, wait an eternity, find the missing package, install manually, then repeat), this finally did the trick. Knitting still takes some time, but at least it generates a PDF. Everything worked smoothly before, so I'd second that notion that there's a glitch somewhere inhibiting the native process of searching for, finding and installing missing components automatically which could also account for why it takes forever to knit to PDF. Thanks again.

@Kasramhdz
Copy link

For others coming to this thread.

It might take a while, but the problem can be fixed with running the package update install by hand (and hoping that it is only a manageable number of packages). You have to knit the file several times to work through all the missing packages.

I ran into a similar issue as reported by @DuGamla above. I work on a windows X laptop. When knitting the Rmd file to pdf, I ended up with

tlmgr.pl: package repository http://ctan.math.illinois.edu/systems/texlive/tlnet (not verified: unknown)
[1/1, ??:??/??:??] install: xcolor [17k]
TLPDB::_install_package: downloading did not succeed (download_file failed)
tlmgr.pl: package log updated: C:/<<my-path-redacted>>/TinyTeX/texmf-var/web2c/tlmgr.log
tlmgr search --file --global "/xcolor.sty"
! LaTeX Error: File `xcolor.sty' not found.

! Emergency stop.

Going back to the R console, I could launch

tinytex::tlmgr_install("xcolor")

which ran nicely echoing the following:

tlmgr install xcolor
tlmgr.pl: package repository http://ctan.math.illinois.edu/systems/texlive/tlnet (not verified: gpg unavailable)
[1/1, ??:??/??:??] install: xcolor [17k]
 running mktexlsr ...
 done running mktexlsr.
 tlmgr.pl: package log updated: C:/<<my-path-redacted>>/TinyTeX/texmf-var/web2c/tlmgr.log

I had to do this for the following packages (xcolor, multirow, wrapfig, colortbl, pdflscape, tabu, varwidth, threeparttable, threeparttablex, environ, trimspaces, ulem, makecell, epstopdf-pkg).

I know too little about how this all works, however, I have the feeling that the attempt to install the packages automatically might have a typo in the repo address or something like this. As I have been able to install the packages by hand (without supplying another repo dir), the issue should be in the download address automatically generated.

In my case installing the missing packages by hand was ok, although I would have loved to be able to avoid the tedious process: (i) knit --> check error for missing package (ii) install by hand and go back to (i). Is there a way to find out what packages are missing and possibly downloading them in one go?

I had similar issue, which was solved through your instruction. Thank you for sharing the solution.

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

7 participants