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

check_installed() returns FALSE for the entire vector when a single package is missing #404

Closed
3 tasks done
ThierryO opened this issue Mar 9, 2023 · 3 comments
Closed
3 tasks done
Labels

Comments

@ThierryO
Copy link

ThierryO commented Mar 9, 2023

The sapply yield to correct output but is much slower.

tex_package <- c(
     "babel", "carlisle", "dvips", "colortbl", "emptypage", "environ", "eso",
     "eurosym", "fancyhdr", "footmisc", "grfext", "helvetic", "hyphen-dutch",
     "hyphen-french", "inconsolata", "lastpage", "makecell", "marginnote",
     "mdframed", "needspace", "oberdiek", "parskip", "pdflscape", "pdfpages",
     "placeins", "tabu", "tex", "times", "threeparttable", "threeparttablex",
     "titlesec", "tocloft", "trimspaces", "ulem", "upquote", "varwidth",
     "wrapfig", "zref"
)
tinytex::check_installed(tex_package)
 [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
sapply(tex_package, tinytex::check_installed)
          babel        carlisle           dvips        colortbl       emptypage         environ             eso 
           TRUE            TRUE            TRUE            TRUE            TRUE            TRUE           FALSE 
        eurosym        fancyhdr        footmisc          grfext        helvetic    hyphen-dutch   hyphen-french 
           TRUE            TRUE            TRUE            TRUE            TRUE            TRUE            TRUE 
    inconsolata        lastpage        makecell      marginnote        mdframed       needspace        oberdiek 
           TRUE            TRUE            TRUE            TRUE            TRUE            TRUE            TRUE 
        parskip       pdflscape        pdfpages        placeins            tabu             tex           times 
           TRUE            TRUE            TRUE            TRUE            TRUE            TRUE            TRUE 
 threeparttable threeparttablex        titlesec         tocloft      trimspaces            ulem         upquote 
           TRUE            TRUE            TRUE            TRUE            TRUE            TRUE            TRUE 
       varwidth         wrapfig            zref 
           TRUE            TRUE            TRUE 
R version 4.2.2 Patched (2022-11-10 r83330)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS, RStudio 2022.12.0.354

Locale:
  LC_CTYPE=nl_BE.UTF-8       LC_NUMERIC=C               LC_TIME=nl_BE.UTF-8        LC_COLLATE=nl_BE.UTF-8    
  LC_MONETARY=nl_BE.UTF-8    LC_MESSAGES=nl_BE.UTF-8    LC_PAPER=nl_BE.UTF-8       LC_NAME=C                 
  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=nl_BE.UTF-8 LC_IDENTIFICATION=C       

Package version:
  graphics_4.2.2  grDevices_4.2.2 stats_4.2.2     tinytex_0.44.1  tools_4.2.2     utils_4.2.2     xfun_0.37      

LaTeX version used: 
  TeX Live 2022 (TinyTeX) with tlmgr 2022-04-18

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('tinytex'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/tinytex').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@cderv
Copy link
Contributor

cderv commented Apr 7, 2023

I am not quite sure what happens here. This works for me.

tex_package <- c(
    "babel", "carlisle", "dvips", "colortbl", "emptypage", "environ", "eso",
    "eurosym", "fancyhdr", "footmisc", "grfext", "helvetic", "hyphen-dutch",
    "hyphen-french", "inconsolata", "lastpage", "makecell", "marginnote",
    "mdframed", "needspace", "oberdiek", "parskip", "pdflscape", "pdfpages",
    "placeins", "tabu", "tex", "times", "threeparttable", "threeparttablex",
    "titlesec", "tocloft", "trimspaces", "ulem", "upquote", "varwidth",
    "wrapfig", "zref"
)
tinytex::check_installed(tex_package)
#>  [1]  TRUE FALSE  TRUE  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE
#> [13] FALSE FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE  TRUE FALSE
#> [25] FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE FALSE  TRUE
#> [37]  TRUE FALSE

The code is quite simple

tinytex/R/tlmgr.R

Lines 160 to 167 in 484d53c

check_installed = function(pkgs) {
if (length(pkgs) == 0) return(TRUE)
res = tryCatch(
tl_list(pkgs, stdout = TRUE, stderr = FALSE, .quiet = TRUE),
error = function(e) NULL, warning = function(e) NULL
)
pkgs %in% res
}

I believe this is because of the tryCatch here - probably something did not work in the call to tlmgr
We do

tlmgr info --list --only-installed --data 'name'

but if it failles, we silently returns res = NULL and so everything is FALSE.

Can you check the command in terminal on your side ? Does this happens again or could it have been temporary ?
Asking because as it is working with sapply(), the command seems to work at some point.

@yihui yihui added the bug label Apr 10, 2023
@yihui yihui closed this as completed in 536662d Apr 10, 2023
@yihui
Copy link
Member

yihui commented Apr 10, 2023

This is a bug. I just fixed it. Thanks for the report!

@cderv
Copy link
Contributor

cderv commented Apr 11, 2023

Oh I see. Thanks @yihui ! and thanks @ThierryO for the report !

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

No branches or pull requests

3 participants