R: build custom installer for windows - r

I am building a custom R installer, following the instruction in "R Installation and Administration" I've installed the latest Rtools212.exe and Inno Setup.
After successfully running tar --no-same-owner -xf R-2.12.1.tar.gz
I've then run make all recommended from R_HOME\src\gnuwin32 and it runs ok until I get the following message:
building package 'base'
cannot create /tmp/R860644: directory nonexistent
mv: cannot stat '/tmp/R860644': No such file or directory
make[3]: ***[mkR] Error 1
make[2]: ***[all] Error 2
make[1]: ***[R] Error 1
make: ***[all] Error 2
After checking the instruction, I thought it was about the environment variable TMPDIR not being set properly. So I tried two options:
create c:\tmp folder
add TMPDIR to the windows environment variable and set the value as c:\DDDD (an existing folder). I then checked the value of TMPDIR in R console by typing Sys.getenv("TMPDIR"), and the change was confirmed.
To my surprise, however, I still got the same error. It looks like: 1. the make commander can not find the default /tmp, which is actually existing; 2. the change of TMPDIR has not been recognized in this occasion, the make commander still try to find the default directory, rather than the changed one.
I also searched online for this problem, and from what I can find, I have done what people had suggested, so now I am stuck.
Can anyone give me some suggestions? Any help appreciated.
Regards,
Shu

well, I just found a solution for my question,
I typed in "set TMPDIR=c:/DDDD" in the command window, and this time no error has been presented.
But I still wonder why my initial tryouts did not work.

Related

Can I change the location of Homebrew FFTW install? R can't seem to read FFTW3.h file located in Cellar folder

I'm trying to install wholebrain by Daniel Fürth, following the instructions on the macosX install page (available here). I am running MacOS Big Sur 11.5.2, R 4.1.2, and RStudio 2021.09.1.
Unfortunately, the program is not straight-forward to install and requires significant developer tools to work correctly. I'm not a programmer and have almost no experience with coding, so I've been mucking through the instructions for two days now trying to get the install to work correctly and I'm firmly stuck on the final step.
In RS, when I run, devtools::install_github("tractatus/wholebrain", INSTALL_opts=c("--no-multiarch")) I get the following error message:
/bin/sh: pkg-config: command not found filter.cpp:9:10: fatal error: 'fftw3.h' file not found #include "fftw3.h" ^~~~~~~~~ 1 error generated. make: *** [filter.o] Error 1 ERROR: compilation failed for package ‘wholebrain’
I have been trying to figure out what this means for quite awhile now and I think I've narrowed it down to R is not reading the location of the fftw header file from where it was installed by Homebrew. (I could be totally wrong, again- not a programmer)
From what I understand, Homebrew always installs under opt/homebrew/cellar. And, in fact, in there is the compiled fftw program with the needed "fftw3.h" file. But for some reason, RStudio is not able to find and read the file in that location.
From random googling and reading of other posted issues, I think that RStudio may expect the file to be under usr/local/include. Can I just copy and paste the header file into that folder? Or will I be screwing something up if I do that? I am totally intimidated by fftw's description of manual compilation so I don't really want to attempt that. Is there a way to change where R is looking for that header file? I already set my wd to "/" so shouldn't R be able to access any folder on my computer?
I want to post an answer here for anyone who comes after me with the same issue. It came down to RStudio not recognizing the programs Homebrew had installed because it wasn't reading the file location where Homebrew saves them. Homebrew always installs programs in /opt/homebrew/... Here is what I had to do:
In RStudio, open your Renviron file using this command: usethis::edit_r_environ()
In the file that opens (which for me was totally blank), type: PATH=/opt/homebrew/bin:${PATH}, or whatever your particular path you want prepended to the Renviron path is.
Quit RStudio and, when prompted, save. Re-open RStudio and run Sys.getenv("PATH") to check. Your new path (in the example above, '/opt/homebrew/bin') should now be prepended to the list of paths that RStudio will use when looking for programs/files. For me this now looks like /opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Applications/RStudio.app/Contents/MacOS/postback
Finally, I want to say thank you very much to Mark Setchell who really helped point me in the correct direction!

Change temporary directory without opening R

Today morning when I tried to start R in my Ubuntu machine, I got a new error saying :
Fatal error: cannot create 'R_TempDir'
However when I search over Internet, I realized that my TMP directory is full as below :
df /tmp
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 81120924 81104540 0 100% /
There is good discussion available how to change that TMP directory here
Change temporary directory
However, this requires opening R and then change modify the .Renviron file. However since I cant open R now, I cant use above solution to my problem.
So, I am looking for some way to modify the TMP directory to some other custom folder e.g. '/opt/R' without opening R
Any suggestion will be highly appreciated.
Thanks,

Rstudio server cannot find correct location of R installation (ubuntu)

I have R 3.4.0 installed to /home/ubuntu/software/R/R-3.4.0/bin, which is a 'non-standard' install location. I then installed rstudio server, and edited the rserver.conf file to include: rsession-which-r=/home/ubuntu/software/R/R-3.4.0/bin
I thought this would be sufficient. At ip:8787 the rstudio server login box appears, and I can login, but then get an error that no session was found.
I also tried adding to the rserver.conf file:
rsession-ld-library-path=/home/ubuntu/software/R/R-3.4.0/bin
but this failed to even load the rstudio login page at ip:8787. After removing this line I now cannot even get back to the login page.
What is going wrong here? Linux has been a nightmare for me, it's been missing file after missing file error, EVEN after I blatantly set LD env variables to the correct paths (via LD_config, make.config files AND configuration files). I feel like I'm missing something fundamental here.
What is the correct command to install R to Rstudio's expected path, if there's no sane way to tell rstudio-server it's in a non-standard path? I used:
./configure --prefix=/home/ubuntu/software/R/R-3.4.0 --with-x=yes --enable-R-shlib=yes --with-cairo=yes
make
to install.
Additional info:
cat /var/log/user.log | grep rstudio
- nothing
cat /var/log/syslog | grep rstudio
- many errors, first: ERROR R did not return any output when queried for directory location information
sudo rstudio-server verify-installation
- ERROR R script path (/home/ubuntu/software/R/R-3.4.0/bin) is a directory rather than a file
Issue was with
`rsession-ld-library-path=/home/ubuntu/software/R/R-3.4.0/bin`
The rconfig file needs to point to a file (not dir), should be:
rsession-ld-library-path=/home/ubuntu/software/R/R-3.4.0/bin‌​/R

Moving directory after compilation of R

I compiled R in /tmp/R-3.0.0 and then moved it to /home/user/opt/R-3.0.0, then I got an error when executing R:
/home/kaiyin/opt/R-3.0.0/bin/R: line 236: /tmp/R-3.0.0/etc/ldpaths: No such file or directory
ERROR: R_HOME ('/tmp/R-3.0.0') not found
If I export R_HOME='/home/kaiyin/opt/R-3.0.0', it still gives almost the same error:
WARNING: ignoring environment value of R_HOME
/home/kaiyin/opt/R-3.0.0/bin/R: line 236: /tmp/R-3.0.0/etc/ldpaths: No such file or directory
ERROR: R_HOME ('/tmp/R-3.0.0') not found
Is there a way to solve this, or do I have to recompile it?
You are supposed to do
configure [...]
make
make install
rather than a manual move. This is a very standard process for source code on Unix system following the GNU conventions.
For more details, please see the manual R Installation and Administration that came with the sources.
There are also pre-built binaries for several distributions.

How to remove files from a Windows folder using the shell() command

I have s script that produces a lot of small PNG files that I want to remove when I close my gWidgets interface. I thought I could do that in Windows using
shell( "del *.png" )
but neither in the script nor in interactive mode in R (2.15.2), this has any effect at all (not even an error or warning). Probably I'm doing something wrong but I can't find out so far what.
Has somebody an idea for me?
I've just tested your command -- same version of R on Windows XP -- and it works exactly as you would expect. If this command is not working for you, I strongly suspect that R's working directory may be different from the directory in which you have your .png files.
You could try:
shell('dir *.png')
... to verify that the .png files are, in fact, in the current working directory before trying to delete them. If they are not there, you will get the report:
File Not Found
Warning messages:
1: running command 'C:\WINDOWS\system32\cmd.exe /c dir *.png' had status 1
2: In shell("dir *.png") : 'dir *.png' execution failed with error code 1
Also, if you've run the del command once, so there are no .png files remaining in the directory, the second time that you run that command you should get an error message like the following:
> shell("del *.png")
Could Not Find C:\usr\sjl\dev\test\R\*.png

Resources