rhmiscrenv

Cannot install Hmisc using renv: Installing Formula [1.2-4] ... FAILED


when trying to install Hmisc in R using renv I get the message underneath. Could somebody help me please?

I'm using:

R version 4.2.0 (2022-04-22) -- "Vigorous Calisthenics", with
RStudio 2022.02.3 Build 492, using a 
Platform: x86_64-apple-darwin17.0 (64-bit), and  
renv 0.14.0

--

Installing 'Hmisc' ...
[1/6] Installing Formula...
Retrieving 'https://cran.rstudio.com/bin/macosx/contrib/4.2/Formula_1.2-4.tgz' ...
    OK [file is up to date]
Installing Formula [1.2-4] ...
    FAILED

Error in if (eval(cond, envir = environment(dot))) return(eval(expr, envir = environment(dot))) :  the condition has length > 1

Calls: sourceWithProgress ... renv_scope_install -> renv_scope_install_macos -> case

In addition: Warning message: 
In system2(R(), args, stdout = TRUE, stderr = TRUE) : running command ''/Library/Frameworks/R.framework/Resources/bin/R' CMD config CC 2>&1' had status 1
Traceback (most recent calls last):

15: sourceWithProgress(script = "/var/folders/y9/8c6qs4hj6pq1nnv725g7gbxw0000gn/T/9878-ce12-709e-35eb", 
        encoding = "UTF-8", con = stdout(), importRdata = NULL, exportRdata = NULL)

14: eval(statements[[idx]], envir = sourceEnv)

13: eval(statements[[idx]], envir = sourceEnv)

12: renv::install("Formula")

11: renv_install_impl(records)

10: renv_install_staged(records)

 9: renv_install_default(records)

 8: handler(package, renv_install_package(record))

 7: renv_install_package(record)

 6: withCallingHandlers(renv_install_package_impl(record), error = function(e) {
        vwritef("\tFAILED")
        writef(e$output)
    })

 5: renv_install_package_impl(record)

 4: r_cmd_install(package, path)

 3: renv_scope_install()

 2: renv_scope_install_macos(.envir)

 1: case(matches("/usr/bin/clang") ~ TRUE, matches("clang") ~ Sys.which("clang") == 
        "/usr/bin/clang", FALSE)

Execution halted

Solution

  • This part of the stack trace:

     < ... >
     3: renv_scope_install()
    
     2: renv_scope_install_macos(.envir)
    
     1: case(matches("/usr/bin/clang") ~ TRUE, matches("clang") ~ Sys.which("clang") == 
            "/usr/bin/clang", FALSE)
    

    suggests that something went wrong when renv was trying to query information about the system compiler.

    Somewhat surprisingly, whenever one upgrades to a new version of macOS, any existing command line tools (CLT) installation will be removed, and needs to be manually re-installed. renv relies on these command line tools being available when querying information about the system's installation capabilities, so re-installing command line tools with:

    xcode-select --install
    

    should alleviate the issue.

    I've also made some changes in the development version of renv to ensure that this situation is handled and reported better.