Error after running build() to create R package in RStudio - windows

I am trying to build an R package using RStudio on Windows 8 Pro. When I attempt to build the package by running build() I get the error:
"C:/Program Files/R/R-30~1.2/bin/x64/R" --vanilla CMD build "H:\File Assembly\FileAssembler" \
--no-manual --no-resave-data
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
Error: Command failed (1)
I already have MiKTEX installed and I have checked this by:
Sys.which("pdflatex")
pdflatex
"C:\\Program Files (x86)\\MIKTEX~1.9\\miktex\\bin\\pdflatex.exe"
The R version I am using is: R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
Loading library(devtools) and running find_rtools(T) gives:
find_rtools(T)
Scanning path...
ls : c:\Rtools\bin\ls.exe
gcc: c:\Rtools\GCC-46~1.3\bin\gcc.exe
VERSION.txt
Rtools version 3.1.0.1942
Version: 3.1
[1] TRUE
In addition, the path for rtools exes are:
Sys.which("ls.exe")
ls.exe
"c:\\Rtools\\bin\\ls.exe"
Sys.which("gcc.exe")
gcc.exe
"c:\\Rtools\\GCC-46~1.3\\bin\\gcc.exe"
And checking the path in R:
Sys.getenv('PATH')
[1] "C:\\Program Files\\R\\R-3.0.2\\bin\\x64;c:\\Rtools\\bin;c:\\Rtools\\gcc-4.6.3\\bin;……other paths…………;C:\\Program Files (x86)\\MiKTeX 2.9\\miktex\\bin\\"
I would really appreciate help with identifying what I have missed out.

This is a common error caused by a space in the install location path (C:\Program Files). The solution, and the official R recommendation is that you never install R in a location with spaces in it on Windows if you want to be able to install packages from source.
from http://cran.r-project.org/bin/windows/rw-FAQ.html#How-do-I-install-R-for-Windows_003f:
If you want to be able to build packages from sources, we recommend
that you choose an installation path not containing spaces.

I had the same problem.
Took some time to find that Rcmd.exe was removed by the Kaspersky antivirus.
once I detected that it was easy to fix.
good luck
Offer

Related

R-INLA installation fails on R 4.1.1

I need to install R-INLA on R 4.1.1 (Windows 10). I cannot update the R version due to compatibility issues of the newer R installations with other tools I that use. I tried the line:
remotes::install_version("INLA", version="22.05.03",repos=c(getOption("repos"),INLA="https://inla.r-inla-download.org/R/testing"), dep=TRUE)
As recommended on the INLA website for R 4.1. I get this message in return:
* installing *binary* package 'INLA' ...
cp: unknown option -- )
Try '/usr/bin/cp --help' for more information.
ERROR: installing binary package failed
* removing 'C:/Program Files/R/R-4.1.1/library/INLA'
I have rtools40 installed and added to my path. I have installed the two suggested packages graph and Rgraphviz as recommended.
I have also tried:
devtools::install_github(repo = "https://github.com/hrue/r-inla", ref = "stable", subdir = "rinla", build = FALSE)
But no luck there either.
If I type where cp in the RStudio terminal, I get:
$ where cp
C:\Program Files\Git\usr\bin\cp.exe
C:\rtools40\usr\bin\cp.exe
But I am not sure if this has anything to do with R not finding cp.
Anyone has any advice?
I was having the same problem, and solved it for my Windows 10 machine:
Download the INLA_22.05.03.zip file at https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.1/
In RStudio, under the Tools menu, select Install Packages, and Install from: Package Archive File. Tell RStudio where the .zip file is located on your local machine. From there it installed fine for me.

Can't install cargo-binutils library: Failed to find tool. Is `gcc.exe` installed?

When I run cargo install cargo-binutils, I get the below error. I have gcc installed and in my path, to the point where where gcc correctly returns the location.
gcc version: gcc.exe (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0
I couldn't find a solution to work, including the explanation in the link listed in the error. I'm on Windows 10.
error: failed to run custom build command for \`backtrace-sys v0.1.37`
Caused by:
process didn't exit successfully: \`C:\Users\blahblah\AppData\Local\Temp\cargo-installEvEWRS\release\build\backtrace-sys-075604757ab74d2a\build-script-build` (exit code: 1)
--- stdout
cargo:rustc-cfg=rbt
TARGET = Some("x86_64-pc-windows-gnu")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-pc-windows-gnu")
CC_x86_64-pc-windows-gnu = None
CC_x86_64_pc_windows_gnu = None
HOST_CC = None
CC = None
CFLAGS_x86_64-pc-windows-gnu = None
CFLAGS_x86_64_pc_windows_gnu = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
running: "gcc.exe" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "src/libbacktrace" "-I" "C:\\Users\\BRENDA~1.BUR\\AppData\\Local\\Temp\\cargo-installEvEWRS\\release\\build\\backtra
ce-sys-1e77a4d4c3ba2eda\\out" "-fvisibility=hidden" "-DBACKTRACE_SUPPORTED=1" "-DBACKTRACE_USES_MALLOC=1" "-DBACKTRACE_SUPPORTS_THREADS=0" "-DBACKTRACE_SUPPORTS_DATA=0" "-DHAVE_DL_ITERATE_PHDR=
1" "-D_GNU_SOURCE=1" "-D_LARGE_FILES=1" "-Dbacktrace_full=__rbt_backtrace_full" "-Dbacktrace_dwarf_add=__rbt_backtrace_dwarf_add" "-Dbacktrace_initialize=__rbt_backtrace_initialize" "-Dbacktrac
e_pcinfo=__rbt_backtrace_pcinfo" "-Dbacktrace_syminfo=__rbt_backtrace_syminfo" "-Dbacktrace_get_view=__rbt_backtrace_get_view" "-Dbacktrace_release_view=__rbt_backtrace_release_view" "-Dbacktra
ce_alloc=__rbt_backtrace_alloc" "-Dbacktrace_free=__rbt_backtrace_free" "-Dbacktrace_vector_finish=__rbt_backtrace_vector_finish" "-Dbacktrace_vector_grow=__rbt_backtrace_vector_grow" "-Dbacktr
ace_vector_release=__rbt_backtrace_vector_release" "-Dbacktrace_close=__rbt_backtrace_close" "-Dbacktrace_open=__rbt_backtrace_open" "-Dbacktrace_print=__rbt_backtrace_print" "-Dbacktrace_simpl
e=__rbt_backtrace_simple" "-Dbacktrace_qsort=__rbt_backtrace_qsort" "-Dbacktrace_create_state=__rbt_backtrace_create_state" "-Dbacktrace_uncompress_zdebug=__rbt_backtrace_uncompress_zdebug" "-D
macho_get_view=__rbt_macho_get_view" "-Dmacho_symbol_type_relevant=__rbt_macho_symbol_type_relevant" "-Dmacho_get_commands=__rbt_macho_get_commands" "-Dmacho_try_dsym=__rbt_macho_try_dsym" "-Dm
acho_try_dwarf=__rbt_macho_try_dwarf" "-Dmacho_get_addr_range=__rbt_macho_get_addr_range" "-Dmacho_get_uuid=__rbt_macho_get_uuid" "-Dmacho_add=__rbt_macho_add" "-Dmacho_add_symtab=__rbt_macho_a
dd_symtab" "-Dmacho_file_to_host_u64=__rbt_macho_file_to_host_u64" "-Dmacho_file_to_host_u32=__rbt_macho_file_to_host_u32" "-Dmacho_file_to_host_u16=__rbt_macho_file_to_host_u16" "-o" "C:\\User
s\\BRENDA~1.BUR\\AppData\\Local\\Temp\\cargo-installEvEWRS\\release\\build\\backtrace-sys-1e77a4d4c3ba2eda\\out\\src/libbacktrace/alloc.o" "-c" "src/libbacktrace/alloc.c"
--- stderr
error occurred: Failed to find tool. Is `gcc.exe` installed? (see https://github.com/alexcrichton/cc-rs#compile-time-requirements for help)
https://github.com/alexcrichton/cc-rs#compile-time-requirements says:
Windows platforms targeting MinGW (e.g. your target triple ends in -gnu)
require cc to be available in PATH. We recommend the
MinGW-w64 distribution, which is using the
Win-builds installation system.
You may also acquire it via
MSYS2, as explained [here][msys2-help]. Make sure
to install the appropriate architecture corresponding to your installation of
rustc. GCC from older MinGW project is compatible
only with 32-bit rust compiler.
Try creating a symlink or hardlink to GCC called cc, somewhere on your path.
This happened to me as well. In my case I got:
failed to run custom build command for zstd-sys v2.0.1+zstd.1.5.2
Caused by: process didn't exit successfully:
C:\Users\asili\Documents\Programming\zero2prod\target\debug\build\zstd-sys-f37cc8bfd3eec6ac\build-script-build
(exit code: 1)
error occurred: Failed to find tool. Is gcc.exe installed? (see
https://github.com/alexcrichton/cc-rs#compile-time-requirements for
help)
I was able to solve it by following the steps on installing the Visual C++ extension from the VS Code marketplace.
This is how I did it:
Go to MSYS2.org https://www.msys2.org/ (You will also see the installation steps on the site, in case this answer gets outdated).
Download and install msys2-x86_64-20220603.exe (or whichever version is current). The installation is pretty straightforward, just take a note on the installation path as you will need to add this to the environment PATH later on.
A new program called "MSYS2" should've been installed. Open it, and you'll see a terminal window in it. You will run ALL of the commands mentioned below in this terminal. If you close it, open it again.
Run:
pacman -Syu
This will update the packages and databases.
Run (Again - This step may not be needed, but is recommended by MSYS2 in case packages need an additional updates.)
pacman -Syu
Run:
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
You will now see a selection of all the packages. If you don't know which to choose, just press enter on your keyboard and you shall get all of them (that's what I ended up doing).
After that, gcc.exe will be installed the bin folder of mingw64. Therefore:
Add theC:\msys64\mingw64\bin file path to your path environment variable (or Wherever you decided to install it).
In case you need assistance on adding to the path, check out this link.
Remember to restart your CMD/Windows Terminal/Power Shell for the environment path to take place.

Error while installing Alien::XGBoost library

I'm unable to install the Alien::XGBoost library using the default installation of Strawberry Perl on Windows 10. I'm using the 64-bit version of Strawberry Perl.
When installing Alien::XGBoost, I receive an error on line 49 in the Alien/Build/CommandSequence.pm file as shown below.
gmake[1]: Leaving directory 'C:/STRAWB~1/cpan/build/Alien-XGBoost-0.04-1/_alien/build_wYwS'
Alien::Build::CommandSequence> + md "C:/STRAWB~1/cpan/build/Alien-XGBoost-0.04-1/blib/lib/auto/share/dist/Alien-XGBoost/dynamic"
Alien::Build::CommandSequence> + md "C:/STRAWB~1/cpan/build/Alien-XGBoost-0.04-1/blib/lib/auto/share/dist/Alien-XGBoost/bin"
Alien::Build::CommandSequence> + copy xgboost.exe C:/STRAWB~1/cpan/build/Alien-XGBoost-0.04-1/blib/lib/auto/share/dist/Alien-XGBoost/bin/
The syntax of the command is incorrect.
external command failed at C:/Strawberry/perl/site/lib/Alien/Build/CommandSequence.pm line 49.
gmake: *** [Makefile:2881: _alien/mm/build] Error 2
PABLROD/Alien-XGBoost-0.04.tar.gz
C:\STRAWB~1\c\bin\gmake.exe -- NOT OK
Stopping: 'install' failed for 'Alien::XGBoost'.
The author of the library just confirmed it was a bug. His statement is below. I installed the previous version and it worked perfectly.
Thanks for reporting this!!
It's a bug! I forgot to quote the path.
As you can see both md commands have the path double quoted (""), but not the copy command.
I'm working to fix it and also I'm going to get travis and appveyor integrations to avoid this in the future.
This weekend this will be fixed. Meanwhile please install the previous version:
cpanm PABLROD/Alien-XGBoost-0.03.tar.gz

Build R source code from windows

C:\Work\R contains the R-3.1.1.tar.gz file
I have build R source(R-3.1.1) in windows 8 from the following commands
cd C:\Work\R
tar --no-same-owner -xf R-3.1.1.tar.gz
cd C:\Work\R\R-3.1.1\src\gnuwin32\
make all recommended
Add the following path to the Environment variables
C:\Work\R\R-3.1.1\bin\i386
Enter the R.exe in command promt
I got the following Error
Fatal error unable to open the base package
System information
Windows 8, 64 bit operating System, x64 –based processor
How to resolve this error?
If you are using R, you can download the newest version from here and then simply install it.
If you have an older version and want only to download the new one, use those commands inside R:
# installing/loading the package:
if(!require(installr)) {
install.packages("installr"); require(installr)} #load / install+load installr
# using the package:
updateR() # this will start the updating process of your R installation. It will check for newer versions, and if one is available, will guide you through the decisions you'd need to make.
We can resolve this issue by using the following command before build the R source code
Set TMPDIR=c:\cygwin64\bin
Here c:\cygwin64\bin is the cygwin installed location in Windows 8 machine.
Here I have mentioned the R source code build steps:
Install cygwin setup
Install RTools
Create the R_HOME file in the directory like C:\R_HOME
Place the R source code tar file in the R_HOME
Add the following path in environment variable in first
c:\Rtools\bin\;c:\Rtools\gcc-4.6.3\bin;C:\cygwin64\bin\;C:\Program Files (x86)\HTML Help Workshop\;C:\R_HOME\R-3.1.1\bin\;
Enter the following command in the command prompt
Set TMPDIR=C:\cygwin64\bin
Set working directory as C:\R_HOME
Enter the following command
tar --no-same-owner -xf R-3.1.1.tar.gz
Copy the Tcl source from c:\R (it will be created while installing RTools)
Set the working directory as follow in command prompt
C:\R_HOME\R-3.1.1\src\gnuwin32
Enter the following command
Make all recommended
Enter the R.exe command in command prompt. We can enter the R terminal

Error building openssl-sys crate on Windows

I am trying to compile a Rust program on Windows, but I get this error message:
Compiling openssl-sys v0.6.4
failed to run custom build command for `openssl-sys v0.6.4`
[...]
failed to execute command: The system couldn't find the specified file. (os error 2)
Is `gcc` not installed? (see https://github.com/alexcrichton/gcc-rs#windows-notes for help)
--- stderr
thread '<main>' panicked at 'explicit panic', C:\Users\User\.cargo\registry\src\github.com-0a35038f75765ae4\gcc-0.3.12\src\lib.rs:510
Cargo compiled every other package without problem, but it can't compile the openssl package.
I searched for help with this specific error and found a github issue for hyperium. The first answer references the openssl building guide for Windows.
I don't understand exactly how I have to build openssl in Windows. I installed MinGW and added the bin path to the global PATH variable, so gcc is reachable, but this did not solve the error.
I use Rust 1.2 and Cargo 0.4.0. My project is an example for a Telegram API wrapper.
1) Download ssl
Installs Win32 OpenSSL v1.0.2d
Install it here: C:\OpenSSL-Win32,C:\OpenSSL-Win32\include,C:\OpenSSL-Win32\lib
2) Install MinGW,and add system env path ,,C:\MinGW\bin,important,MinGW's installed path contain char 'MinGW '
3) cmd run env OPENSSLLIBDIR=C:/OpenSSL-Win32/lib OPENSSLINCLUDEDIR=C:/OpenSSL-Win32/include cargo build

Resources