Christophe Bousquet
2023-Aug-31 14:59 UTC
[R] Problems with installing R packages from source and running C++ in R, even on fresh R installation
> This can be considered good news. You have just successfully performed > the job that is normally done by R CMD SHLIB when installing source > packages or running inline C++ code. The environment variables, at > least inside your running R session, are completely fine. > > Now we need to find out why R CMD SHLIB itself fails without producing > any output. Do you get any output from tools::Rcmd('SHLIB --version')? > Does tools::Rcmd('') print the list of available options?Thanks again. Here is the output before I changed anything in PATH: ```> tools::Rcmd('SHLIB --version') > tools::Rcmd('')Usage: Rcmd command args where 'command' is one of: INSTALL Install add-on packages REMOVE Remove add-on packages SHLIB Make a DLL for use with dynload BATCH Run R in batch mode build Build add-on packages check Check add-on packages Rprof Post process R profiling files Rdconv Convert Rd format to various other formats Rdiff difference R output files Rd2pdf Convert Rd format to PDF Rd2txt Convert Rd format to pretty text Stangle Extract S/R code from vignette Sweave Process vignette documentation config Obtain configuration information about R open Open a file via Windows file associations texify Process a latex file Use Rcmd command --help for usage information for each command. ``` So I get no output for tools::Rcmd('SHLIB --version'). I tried to run tools::Rcmd('SHLIB --help') or tools::Rcmd('check --help'), but no output neither. I had more success with tools::Rcmd('BATCH --help'): ```> tools::Rcmd('BATCH --help')Usage: Rcmd BATCH [options] infile [outfile] Run R non-interactively with input from infile and place output (stdout and stderr) to another file. If not given, the name of the output file is the one of the input file, with a possible '.R' extension stripped, and '.Rout' appended. Options: -h, --help print short help message and exit -v, --version print version info and exit --no-timing do not report the timings -- end processing of options Further arguments starting with a '-' are considered as options as long as '--' was not encountered, and are passed on to the R process, which by default is started with '--restore --save'. Report bugs at <https://bugs.R-project.org>. ``` I get exactly the same output after adding the paths to PATH in the System variables part of the Environment variables box and before restarting my computer. I had to change the / to \\ because my computer does not allow the sign / for paths. So C:\\rtools43/x86_64-w64-mingw32.static.posix/bin became C:\\rtools43\\x86_64-w64-mingw32.static.posix\\bin After restart, I get the same output. I can also add that: ```> tools::Rcmd('BATCH --version')R batch front end: 4.3.1 (r84548) Copyright (C) 1997-2023 The R Core Team. This is free software; see the GNU General Public Licence version 2 or later for copying conditions. There is NO warranty. ``` Best regards, Christophe
Ivan Krylov
2023-Aug-31 19:43 UTC
[R] Problems with installing R packages from source and running C++ in R, even on fresh R installation
? Thu, 31 Aug 2023 14:59:07 +0000 Christophe Bousquet <chr_bousquet at protonmail.com> ?????:> So I get no output for tools::Rcmd('SHLIB --version'). > > I tried to run tools::Rcmd('SHLIB --help') or tools::Rcmd('check > --help'), but no output neither. > > I had more success with tools::Rcmd('BATCH --help'):The job of Rcmd.exe is to figure out where it's located and pass the correct arguments to Rterm.exe (or some of the few other executables). In a few cases (like `R CMD BATCH --help` or just `R CMD` without arguments) it understands enough to produce the output by itself, which you see. In most other cases (`SHLIB` or `check` with any arguments), it constructs the command line to launch "${R_HOME}/bin/x64/Rterm.exe" -e <something> and forwards the command line arguments there. For some reason, the command line fails to produce any output. Is there a "C:\Program Files\R\R-4.3.1\bin\x64\Rterm.exe"? If you launch it, does it present an R command line? I'm suspecting that Rcmd.exe somehow messes up when it tries to locate Rterm.exe to launch it. Here's one way to see what happens: 1. Download Sysinternals Process Monitor, a free monitoring utility, from the Microsoft website and launch it (no installation needed): https://learn.microsoft.com/en-us/sysinternals/downloads/procmon 2. Set up the filter so that so that entries are included - Process name is "Rcmd.exe" - Operation is "Process Create" 3. Run tools::Rcmd('SHLIB --help') (or any other Rcmd invocation that fails to produce any output for you) 4. You should get one event of Rcmd.exe trying to launch cmd.exe with a long command line. What is the command line? -- Best regards, Ivan