I have Rcpp-based C++ code with a memory access bug which is only revealed when compiling vignettes (both in classic R and devtools manners).
The crashing code runs fine on its own in vanilla R environment.
I've tried things like:
R -d gdb --vanilla -e "devtools::build()"
R -d gdb --vanilla -e "devtools::check()"
but after digging deep I find that both devtools and R start new processes to build the vignettes during either building or checking a package.
I therefore modified /usr/lib/R to always be invoked -d gdb -ex run but this wouldn't run because it messed up the complicated argument passing between each of the steps.
I've no idea how to proceed at this point as I can't even reproduce the error with a simple R command invoking the compiled code. Could this be an unexpected interaction of Rcpp or other packages which differs between the vignettes building and vanilla interactive environment?
Related
I'm in a team that is running multiple cronjobs that call R scripts from a remote machine (macos). My colleague needs to run 3.6 for a new script, while a package that is essential to mine has not been updated for it yet. I'm trying to put multiple installations on the same computer so we just specify which "R" version to call in the cronjob.
I know installing from source isn't recommended on macos, so I've been trying to follow the directions here https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Multiple-versions and ran the pkgutil --forget commands to prevent the R 3.6 installation from overwriting the R.framework/Versions/3.5 directory.
Here are the pkgutil commands that I ran:
sudo pkgutil --forget org.r-project.x86_64.tcltk.x11
sudo pkgutil --forget org.r-project.R.el-capitan.GUI.pkg
sudo pkgutil --forget org.r-project.R.el-capitan.fw.pkg
sudo pkgutil --forget org.r-project.x86_64.texinfo
Yet after installing 3.6 from CRAN, when I run the following line:
Library/Frameworks/R.framework/Versions/3.5/Resources/bin/R
Instead of the 3.5.3 console running in the terminal, the 3.6 console pops up.
I'm confused with what to do here - I've also used
ls -la 3.5/Resources/bin | grep "/->"
to check and see if a symlink was created during the install that would change the version/location but get no results, and when I run Rscript --version in the same directory as the R path shown above, I get the following output:
R scripting front-end version 3.5.3 (2019-03-11)
Though when I try to run my script using this location of Rscript I get the same error that I did when running it using R 3.6. However, once I reinstalled R 3.5.3 the script ran fine.
Basically, I think somehow the most recently installed version of R seems to override and run no matter what I do to try and insure that an older version runs instead. Can someone help me piece together how or why this is happening, or provide a suggestion as to how to install R 3.6 as the default "R" while still allowing me to run 3.5.3 for certain scripts as needed?
I have similar problem. What you observed is clearly mentioned on https://cran.rstudio.org/doc/manuals/R-admin.html#Uninstalling-under-macOS: "However, R.APP will always run the ‘current’ version, that is the last installed version.". So far, I don't know how to solve the problem either. Using Rswitch worked very well to switch R versions manually, but i don't know how to integrate Rswitch to command lines.
I am writing an R package and build and test it with:
Rscript -e "devtools::document()" && R CMD build . && Rscript -e "devtools::test();devtools::check()"
I get a note:
checking top-level files
Non-standard file/directory found at top level:
‘PosteriorBootstrap_0.0.1.tar.gz’
I get the note whether devtools::check() comes first or second.
This
thread suggests:
The note is telling you that you usually shouldn't have a file called
build in the top level of your package.
The tar.gz file is created by R CMD build and I get the same error even if I delete it before running it.
This
thread
suggests adding the tar.gz file to .Rbuildinore, which removes the note.
Another way to remove it is to run everything from devtools:
Rscript -e "devtools::document(); devtools::build(); devtools::load_all('.'); devtools::test(); devtools::check()"
And then I don't get that note.
What's the difference between R CMD build and devtools::build() and why does the former throw that note?
You are combining a number of steps that perform similar and/or competing functions. I would suggest reading this for a best-practice build and check workflow.
When you run R CMD build it builds the package to the current directory, which is the top level package directory. Therefore, when you run your checks, it sees the .tar.gz file in the package root, which is a non-standard file to have in a package, thus the warning. devtools::build() is smart and builds the package to the package parent directory (regardless of where you are calling it from). Trying to call R CMD commands mixed with devtools functions can create issues, because devtools also calls R CMD commands, so you may be duplicating actions at various points in time or causing commands to be called in the incorrect order.
Per the link above, a best-practice workflow would be:
Rscript -e "devtools::document();devtools::check();devtools::build()"
called from the package root, and you avoid dealing with R CMD altogether. If you want to use R CMD it would look something like this:
Rscript -e "devtools::document()" && cd .. && R CMD build PosteriorBootstrap && R CMD check PosteriorBootstrap*.tar.gz
starting in the package root and then changing to the parent directory.
I've recently compiled R on Ubuntu Server 16.04. I'm attempting to run an R Script using the Rscript function, but I'm running into errors.
When I run the script using Rscript, the output shows the functions as() and new() from the methods package included in the R distribution cannot be found. When I run R interactively, I'm able to use these functions without any problem.
Any help would be tremendously appreciated!
It is a design bug in Rscript: it does not load methods on startup.
Two fixes:
Add library(methods) to your script, or
Do sudo apt-get install r-cran-littler and use r instead of Rscript.
r has been loading methods since day one as this behaviour of Rscript never really made sense.
I've recently compiled R on Ubuntu Server 16.04. I'm attempting to run an R Script using the Rscript function, but I'm running into errors.
When I run the script using Rscript, the output shows the functions as() and new() from the methods package included in the R distribution cannot be found. When I run R interactively, I'm able to use these functions without any problem.
Any help would be tremendously appreciated!
It is a design bug in Rscript: it does not load methods on startup.
Two fixes:
Add library(methods) to your script, or
Do sudo apt-get install r-cran-littler and use r instead of Rscript.
r has been loading methods since day one as this behaviour of Rscript never really made sense.
I am relatively new to R, and have no experience with Linux or C. I need to compile a .c program that I can later call from R. I installed Cygwin, and used the cd command to change to the R/R-2.14.0/bin directory. I verified this using the ls command. I also copied the foo.c program into the same directory. However, when I attempt to execute the "R CMD SHLIB foo.c" command I get the following error message:
-bash: R: command not found
Is there something else I need to do?
Actually, that was all I needed to know (that I needed to use RTools). I was using a hardcover reference, that recommended Cygwin.. but that turned out to be a dead-end for me. I installed RTools, and was able to compile the program, load it into R and execute it.