opening RStudio generates a 0 kb git.exe file - r

I am using R Studio 2022.02.3 Build 492 with R 4.2.0 -- "Vigorous Calisthenics" on a Win 10 PC.
When I double click on a R file, i.e. a R script, R studio opens and a 0 KB git.exe file is generated in the folder where my .R file was located.
I can not find any relevant information about this (my searches points towards using Git from RStudio). This started yesterday without any conscious change from my part and updating R and RStudio did not help.
Is this something I should be worried about?
How can stop this from happening?
Some more system info/specification:
it is a git.exe file (0 KB). Nor a git folder or anything else.
Date/time of git.exe (as shown in windows explorer) is similar to when I double click on the .R file
R is in its default place: Windows/Program files/R
RStudio is in its default place: Windows/Program files/RStudio
In RStudion, Git/SVN options are default, i.e.: Git executable: (Not Found); SVN executable (Not Found), SSH RSA key: (None)

Related

Compiling R from source: RStudio doesn't find the libraries if started directly

I have compiled R 4.1.0 from source against the Intel MKL.
I have put:
source /opt/intel/oneapi/mkl/latest/env/vars.sh intel64
in ~/.bashrc.
If I open a .R file with RStudio, no problem.
But if I open RStudio directly, it is unable to start R correctly, giving me the error:
/usr/lib/rstudio/bin/rsession: error while loading shared libraries: libmkl_gf_lp64.so.1: cannot open shared object file: No such file or directory
Why is that? Doesn't RStudio run ~/.bashrc when started directly?
I am running Fedora 34 Workstation.
When shared libraries are stored in "non-standard locations" we have to tell the dynamic linker about it. That is sometimes done in the calling script (often the case with bundled software, e.g. when you download RStudio which ships with a fair number of local builds of shared libraries) but a more general solution is to tell ldconfig via its configuration.
Older systems used a line per directory in /etc/ld.so.conf. Newer systems generalize this (like many other configurations) with a directory containing small files with entries. So you can create a file named, say, /etc/ld.so.conf.d/local-mkl.conf, and place the directory path in there. If you then run sudo ldconfig all applications will know about it -- including R and RStudio calling R.

How do you make RStudio remember R installations it used in the past?

I use a separate installation of R for each project.
To make RStudio use the right one I click and hold down the Control key when I start RStudio.
This opens a "Choosing R Installation" pop-up where I can select the R binary I need.
The problem is that - unlike in this RStudio support article - the pop-up shows only the very last version of R that I used.
So whenever I switch projects I have to browse to the R binary that I need.
Is there a way to make RStudio remember the other R versions I've used?
If there isn't, where does RStudio look for the last used one? If I knew that, I could probably use a script to overwrite it before launching RStudio.
Some details:
I am on Windows 7/10.
RStudio version is 1.3.1093
None of the registry keys described here are set.
Since you mentioned that you kept the registry clean and under the assumption that you are using distinct/separate folders for each of your projects one COULD be tempted to try something like
a .Renviron file containing R_HOME=C:/path/to/your/required/version or
a .Rprofile file containing Sys.setenv(R_HOME='path/to/your/version')
in your project folder(s)?
Or potentially put a .bat file in there with content like
SET R_HOME=Path/to/your/R.version
cd /D "%~dp0"
start .YourProject.Rproj
BUT NOPE!
Currently this type of functionality/behaviour is NOT available for RStudio Desktop Free (as of time of writing this is RStudio Desktop 1.3.1093) BUT can only be achieved with RStudio Server PRO - see 6.3.3 User Configurable Default Version.
#Evgenil: updated answer based on your suggestion and after I had the time to test the idea as well
I had a similar problem. The way I solved this was by utilizing portable versions of R and RStudio.
To get this to work I needed a few things.
Download portable versions of R, https://sourceforge.net/projects/rportable/files/
Download portable versions of RStudio, https://sourceforge.net/projects/rportable/files/
Download IniFile 1.92, https://www.horstmuc.de/wbat32.htm#inifile
In this example I have created three folders on my desktop.
BatchSetRandRStudio, R-Portable-4.1.2, RStudio-2022.02.3-492
Example steps:
Create a folder to house the batch file that will launch R and RStudio. e.g. C:\Users<username>\Desktop\BatchSetRandRStudio.
Place the downloaded IniFile, inifile.exe, in the folder you just created for the batch file.
Create a batch file with the example code below and change the paths to your specifications for the portable versions of R and RStudio. e.g. Batch4.1.2RLaunchRStudioRun.bat
#echo off
REM Remember to update the Rprofile.site within each R-Portable location, in the etc folder for each portable R version:
REM C:\Users\<username>\Desktop\R-Portable-4.1.2\App\R-Portable\etc
REM .First = function(){
REM .libPaths(.Library)
REM }
REM Also the portable R library location is located:
REM C:\Users\<username>\Desktop\R-Portable-4.1.2\App\R-Portable\library
:: INI editor; inifile.exe needs to be in same folder of batch file to work
:: Source: https://www.horstmuc.de/wbat32.htm#inifile
:: INIFILE filename [section] item=string
:: inifile.exe "C:\Users\<username>\AppData\Roaming\RStudio\desktop.ini" [General] RBinDir=C:/Users/<username>/Desktop/R-Portable-4.1.2/App/R-Portable/bin/x64
inifile.exe "C:\Users\<username>\AppData\Roaming\RStudio\desktop.ini" [General] RBinDir=C:/Users/<username>/Desktop/R-Portable-4.1.2/App/R-Portable/bin/x64
:: FOR R 4.1.2
:: Start Program
:: start "" "C:\Users\<project folder>\Desktop\RStudio-2022.02.3-492\bin\rstudio.exe"
start "" "C:\Users\<username>\Desktop\RStudio-2022.02.3-492\bin\rstudio.exe"
:: FOR R 4.1.2
:: Start Program and specific project
:: start "" "C:\Users\<username>\Desktop\RStudio-2022.02.3-492\bin\rstudio.exe" "C:\Users\<username>\Desktop\R-Portable-4.1.2\Projects\<project folder>\<project name>.Rproj" & :: This command starts RStudio and opens specific project
Update the Rprofile.site file within each R-Portable location (allows one to have separate package installations for each portable version you create) with the following code:
.First = function(){
.libPaths(.Library)
}
Run the batch file, RStudio should open with the version of R you have pointed it to as well as the version of RStudio you have specified. You should be able to add projects and create specific batch files to open each project separately.

not possible to set the "R home directory path" in Bluesky Statistics

I have problems in setting the "R home directory path" with the latest 64bit release of Bluesky Statistics (6.20.7235). After running the software for the first time, I received the following error:
Error: Cannot Launch BlueSky Statistics! Please make sure:
R_HOME configuration variable is pointing to the correct version of R.
Then, I set the "R home directory path" as follows, but I still got the above error: C:/Program Files/BlueSky Statistics/R-3.6.1
I have the same problem when installing also the 32bit latest version, but not with the 64/32 bit stable release (6.10.7107). There are not other versions of R installed in my laptop.
Here are additional information of my laptop:
OS: Windows 8 64 bit;
CPU: Intel Celeron N2840 2.16 GHz;
RAM: 4 GB.
To fix this issue you can try following:
Find the following location:
C:\Users\YOUR-USERNAME\AppData\Roaming
In the above location you will see a folder named BlueSky. Delete this BlueSky folder to perform the manual cleanup. Launch BlueSky Statistics application and defaults will load automatically and also the BlueSky folder will be created.

How do I open an r script (.R file) in RStudio by double-clicking it in windows

When I double click an R script (.R file) in order to open and edit it, nothing happens.
I expect it to open it in either R or RStudio but it doesn't.
I found a similar (old) question (Opening a .R file via a double click (Windows)) but the solution doesn't work for me.
I have tried:
- right-clicking and explicitly telling it to open it with RStudio
- set it as the default program to associate with this file type
- drag the script into RStudio
Anyone any idea whether it is Windows or R(Studio) related?
Running:
Windows 10 Pro
R version 3.6.1
RStudio version 1.2.1335
As the first comment suggest, it is likely a problem occuring while installing R or Rstudio. This would most likely be fixed by reinstalling Rstudio. If it doesnt i'd suggest checking out this Rstudio question.
Basically, you can manually create using the command prompt (start -> "cmd" -> enter), using
assoc .R=rfile
Ftype rfile="C:\Program Files\RStudio\bin\rstudio.exe" %1
changing the rstudio directory to the correct directory for your computer.
A less command-prompty solution might be available by following the steps described in this guide. However i did not test the latter approach.

How to build qpdf on Windows?

When running the checks for my R-package (via devtools::check()) I face the warning ''qpdf' is needed for checks on size reduction of PDFs. I found this question were it was suggested (if I understood the answer correctly) to run Sys.which(Sys.getenv("R_QPDF", "qpdf")) and see whether qpdf is found or not. In my case this just returns
qpdf
""
so, I think I didn't install qpdf correctly. Unfortunately it seems to be quite complicated to install qpdf on Windows. My first side question is: does it really is so painful and complicated to install qpdf for Windows or is there an easy solution?
I've followed the instructions until it is said to add C:\MinGW-w64\bin and C:\MinGW-w64\lib\mingw to the PATH variable. But then I don't find further specific instructions to install qpdf, only about how to build qpdf with different other programs. The second side question is: is my assumption correct that after I've build qpdf it is installed? But the real question is: What is the best way to build qpdf? I tried the ./config-mingw32 and ./config-mingw64 commands from the section "Building with MinGW" in my C:\MinGW\msys\1.0\bin\bash.exe but got the error messages ./config-mingw32: No such file or directory and have no idea how to fix this issue.
I'm using Windows 10, R version 3.3.2 Patched (2017-01-07 r71934) -- "Sincere Pumpkin Patch" and RStudio 1.0.136.
You basically do not need to build the file on windows. Please follow three steps below:
Download qpdf for windows from https://sourceforge.net/projects/qpdf/?source=typ_redirect
Extract files in a temp folder
Copy the contents of the bin folder to %SystemRoot%\System32
job done!
Sys.which(Sys.getenv("R_QPDF", "qpdf"))
qpdf
"C:\\WINDOWS\\SYSTEM32\\qpdf.exe"
To flesh out an answer provided elsewhere:
If you are running the 32-bit version of R, it is important that you download the 32-bit version of qpdf, which is the version linked from the SourceForge homepage. If you are running a 64-bit installation of R, you will need to do a bit of digging to locate the 64-bit version of qpdf, which is buried a little more deeply (version 10.0.1 is listed here).
Rather than copying files to C:/Windows/System32, a potentially safer option is to extracted the zipped qpdf directory to C:\Program Files. If you do this, you'll need to add C:\Program Files\qpdf-version_number\bin to your system PATH under the environment variables.
To do this within R, run Sys.setenv('PATH' = paste0('C:\Program Files\qpdf-version_numer\bin;', Sys.getenv('PATH')))
To do this in Windows, open the start menu, type "edit the system environment variables" to open the System Properties, and at the bottom of the "Advanced" tab click "Environment variables". Find the "Path" entry under "System variables" and click "Edit". Then, re-start R so it picks up the modified PATH.
One further step may be required to convince Windows that pqdf is safe to run.
Navigate to C:\Program Files\qpdf-version_numer\bin and execute qpdf.exe (by double-clicking). Windows 10 throws up a security warning, as it's an unrecognized executable file. You'll need to use the more options link to find the button to run the program. This done, Windows will recognize the file as safe to run and allow other software, including R, to use it.

Resources