Moving directory after compilation of R - 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.

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!

homebrew not installing JAGS

I'm trying to install JAGS through homebrew so I can use it in R. I am getting the following warning every time I install:
Warning: jags dependency gcc was built with a different C++ standard
library (libstdc++ from clang). This may cause problems at runtime.
Then, when I try to install rjags in R, I get the following error:
configure: error: "cannot link to JAGS library in /usr/local/Cellar/jags/4.3.0_2/lib."
ERROR: configuration failed for package ‘rjags’
* removing ‘/usr/local/lib/R/4.0/site-library/rjags’
I also tried following the installation guide in the JAGS 4.3.0 readme. This yielded the same error once I moved to R.
Googling leads me to the following links, none of which seem closely related enough to help me:
https://github.com/Homebrew/brew/issues/4904
https://github.com/Homebrew/homebrew-core/issues/32112
Link different C++ standard libraries on Mac OS X
Here also is the entire result of my brew doctor
(base) aridf#Aris-MacBook-Pro ~ % brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
/Users/aridf/opt/anaconda3/bin/icu-config
/Users/aridf/opt/anaconda3/bin/krb5-config
/Users/aridf/opt/anaconda3/bin/freetype-config
/Users/aridf/opt/anaconda3/bin/xslt-config
/Users/aridf/opt/anaconda3/bin/libpng16-config
/Users/aridf/opt/anaconda3/bin/libpng-config
/Users/aridf/opt/anaconda3/bin/xml2-config
/Users/aridf/opt/anaconda3/bin/python3-config
/Users/aridf/opt/anaconda3/bin/curl-config
/Users/aridf/opt/anaconda3/bin/ncursesw6-config
/Users/aridf/opt/anaconda3/bin/pcre-config
/Users/aridf/opt/anaconda3/bin/python3.8-config
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libtcl8.6.dylib
/usr/local/lib/libtk8.6.dylib
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
/usr/local/include/fakemysql.h
/usr/local/include/fakepq.h
/usr/local/include/fakesql.h
/usr/local/include/itcl.h
/usr/local/include/itcl2TclOO.h
/usr/local/include/itclDecls.h
/usr/local/include/itclInt.h
/usr/local/include/itclIntDecls.h
/usr/local/include/itclMigrate2TclCore.h
/usr/local/include/itclTclIntStubsFcn.h
/usr/local/include/mysqlStubs.h
/usr/local/include/odbcStubs.h
/usr/local/include/pqStubs.h
/usr/local/include/tcl.h
/usr/local/include/tclDecls.h
/usr/local/include/tclOO.h
/usr/local/include/tclOODecls.h
/usr/local/include/tclPlatDecls.h
/usr/local/include/tclThread.h
/usr/local/include/tclTomMath.h
/usr/local/include/tclTomMathDecls.h
/usr/local/include/tdbc.h
/usr/local/include/tdbcDecls.h
/usr/local/include/tdbcInt.h
/usr/local/include/tk.h
/usr/local/include/tkDecls.h
/usr/local/include/tkPlatDecls.h
Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected .pc files:
/usr/local/lib/pkgconfig/tcl.pc
/usr/local/lib/pkgconfig/tk.pc
Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected static libraries:
/usr/local/lib/libtclstub8.6.a
/usr/local/lib/libtkstub8.6.a
Thanks!
The solution, per https://gist.github.com/casallas/8411082, was to change ~/.R/Makedir to the following:
CC=clang
CXX=clang++
Then reinstall the package in R

Unable to compile AdaControl: unknown project file: "asis"

I downloaded the source for AdaControl from the SourceForge Repo. Using GNAT 2017 CE, I get the following error on make:
$ make build
gprbuild build.gpr adactl -cargs -bargs -largs
build.gpr:1:06: unknown project file: "asis"
gprbuild: "build.gpr" processing failed
make: *** [adactl] Error 4
The instructions make it sound like this is all I need to do, and offer no troubleshooting suggestions:
Go to the root directory of the distribution and type:
make build make install
As this related question notes, I have managed to get ASIS to build, though it also comes packaged with GNAT 2017 CE.
That message means that ASIS4GNAT isn't installed in a place where gprbuild (and the rest of your GCC/Ada tool-chain) can find it.
You can use the command gnatls -v to get an idea about where your GCC/Ada tool-chain expects project files to be located.
Compare that to where you actually installed ASIS4GNAT, and you may be closer to a solution.

Problem loading rJava

Yesterday I removed R2.11 from my system (Win7, 64bit), since I´m working on R2.13.
Since then i get an error message:
> require(rJava)
Lade nötiges Paket: rJava
Error : .onLoad in loadNamespace() fehlgechlagen, Details:
Aufruf: rJava
Fehler: inDL(x, as.logical(local), as.logical(now), ...)
I tried specifying PATH, since I found on the internet that it might have something to do with jvm.dll:
c:\Rtools\bin;
c:\Rtools\perl\bin;
c:\Rtools\MinGW\bin;
c:\Rtools\MinGW64\bin;
C:\Windows\system32;
%R_HOME%\bin;
C:\Program Files\R\R-2.13.0\bin;
C:\Program Files\Java\jre6\bin\server
However I could not solve the problem...
I also can´t run R from the win command line (just type "R"?)
Any suggestions?
Here is some quick advice on how to get up and running with R + rJava on Windows 7 64bit. There are several possibilities, but most have fatal flaws. Here is what worked for me:
Add jvm.dll to your PATH
rJava, the R<->Java bridge, will need jvm.dll, but R will have trouble finding that DLL. It resides in a folder like
C:\Program Files\Java\jdk1.6.0_25\jre\bin\server
or
C:\Program Files\Java\jre6\jre\bin\client
Wherever yours is, add that directory to your windows PATH variable. (Windows -> "Path" -> "Edit environment variables to for your account" -> PATH -> edit the value.)
You may already have Java on your PATH. If so you should find the client/server directory in the same Java "home" dir as the one already on your PATH.
To be safe, make sure your architectures match.If you have Java in Program Files, it is 64-bit, so you ought to run R64. If you have Java in Program Files (x86), that's 32-bit, so you use plain 32-bit R.
Re-launch R from the Windows Menu
If R is running, quit.
From the Start Menu , Start R / RGUI, RStudio. This is very important, to make R pick up your PATH changes.
Install rJava 0.9.2.
Earlier versions do not work! Mirrors are not up-to-date, so go to the source at www.rforge.net: http://www.rforge.net/rJava/files/. Note the advice there
“Please use
`install.packages('rJava',,'http://www.rforge.net/')`
to install.”
That is almost correct. This actually works:
install.packages('rJava', .libPaths()[1], 'http://www.rforge.net/')
Watch the punctuation! The mysterious “.libPaths()[1],” just tells R to install the package in the primary library directory. For some reason, leaving the value blank doesn’t work, even though it should default.
I finally solved the problem:
It seems that rJava searches for jvm.dll in ~\Java\jre6\bin\client.
However this folder didn´t exist on my system (jvm.dll was in ~\bin\server).
So I just made a copy of jvm.dll in a folder ~\bin\client\ and added this to the path.
Now everything works fine!
My problem was solved by
install.packages("SqlRender",INSTALL_opts="--no-multiarch")
It was a package that depends on rJava and all advices were telling me to fix Java installation. But the solution was to use install option that simply forgets about i386 architecture. (also works with drat library and packages not from CRAN)
This may be due to a conflict between RStudio and Java versions. If you have installed 64 bit java and RStudio is running in 32 bit mode, you may experience problems like this. As a solution, you can change the 32-64 bit selection in the Tools-> Global Options-> General section in RStudio.
You can find detailed information here.
In my case installing proper version of Java solved my problem.
I installed 64x bit java, cause I use 64x bit R version.
I solved it by following these steps
setting my environment Sys.setenv(JAVA_HOME='C:\\Program Files (x86)\\Java\\jre6')
Manually installing rJava package from install package (even this should work:
install.packages('rJava', .libPaths()[1], 'http://www.rforge.net/'))
library(rJava)
I solved this problem as follows. I've been trying for 2 days.
Windows 7 users do not write ... \ bin \ x64 in environment variables.
Instead, define the path as follows.
JAVA_HOME "C: \ Program Files \ Java \ jre1.8.0_251"
R_HOME C: \ Program Files \ R \ R-3.5.3
In RStudio type .LibPaths()
This will give you an path in you windows system where your library’s are located
Go there and delete rJava. If it is being used by applications of Java, kill all Java programs in the Task Manager.
Go to computer and properties, click on change environment variables
Edit JAVA_HOME and all Java related paths to the path where your newest installation of Java is located and save.

Question about JRI error

I try to run my R script in Java, thus I installed JRI. and run the example, I am using Eclipse on 64 bits windows 7. part of the example code is as follows:
public static void main(String[] args) {
System.out.println("Creating Rengine (with arguments)");
Rengine re=new Rengine(args, false, null);
System.out.println("Rengine created, waiting for R");
if (!re.waitForR()) {
System.out.println("Cannot load R");
return;
}
However, everytime I run it. it teminated after print out "Creating Rengine (with arguments)" never successfully print out "Rengine created, waiting for R"
I do not know what is right argument to input, I have tried to add "--no-save" under the Program arguments of eclipse run configuration, but still does not help.
any suggestions? Many thanks
Ref: http://www.rforge.net/JRI/
R_HOME must be set correctly
(Windows): The directory containing
R.dll must be in your PATH
(Mac): Well, it's a Mac, so it just
works ;).
(unix): R must be compiled using
--enable-R-shlib and the directory containing libR.so must be in
LD_LIBRARY_PATH. Also libjvm.so and
other dependent Java libraries must
be on LD_LIBRARY_PATH.
JRI library must be in the current
directory or any directory listed in
java.library.path.
Alternatively you can specify its
path with -Djava.library.path=
when starting the JVM. When you use
the latter, make sure you check
java.library.path property first such
that you won't break your Java.
Depending on your system, the R
verison and other features you want
to use, you may have to set
additional settings such as
R_SHARE_DIR, R_INCLUDE_DIR and
R_DOC_DIR.
My own notes:
Installing R on Mac:
Ref: http://cran.r-project.org/mirrors.html
Ref: http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html
Downloaded MacOSX binary R-2.13.0.pkg from http://cran.csiro.au/
Installing Java Interface for R (JIR) on Mac OS X
Ref: http://www.rforge.net/JRI/
JIR is now a part of rJava.
> install.packages("rJava")
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.csiro.au/bin/macosx/leopard/contrib/2.13/rJava_0.8-8.tgz'
Content type 'application/x-gzip' length 769006 bytes (750 Kb)
opened URL
==================================================
downloaded 750 Kb
The downloaded packages are in
/var/folders/ZZ/ZZ7tAIJsFU8FDfPPp7H53++++TM/-Tmp-//RtmpCHz9Mh/dow
> library(rJava)
> .jinit()
> s <- .jnew("java/lang/String", "Hello World!")
> print(s)
[1] "Java-Object{Hello World!}"
Running JRI example Java with Eclipse on Mac OS X
Copied the rJava/jri/examples/rtest.java to Eclipse JRI/src/.
Copied the JRI.jar from the jri directory to the JRI/lib/ and added it to the build path.
The rtest.java compiles but it did not run as a Java application.
Apparently, it needs to be run by: ./run rtest.
After examining the "run" shell script which comes with the rJava package (inside ./jri/), I have set up these in the Eclipse run configuration:
Environnment:
R_HOME = /Library/Frameworks/R.framework/Resources
PATH=/Library/Frameworks/R.framework/Resources/bin/
In addition, the example run shell script sets up the following Environment vars:
R_INCLUDE_DIR=Library/Frameworks/R.framework/Resources/include
R_SHARE_DIR=Library/Frameworks/R.framework/Resources/share
R_DOC_DIR=Library/Frameworks/R.framework/Resources/doce
JRI_LID_PATH=Library/Frameworks/R.framework/Resources/lib:/Library/Frameworks/R.framework/Resources/bin
VM argument:
-Djava.library.path=/Library/Frameworks/R.framework/Resources/library/rJava/jri/
JRI.jar is now referenced in the build path, which is:
/Library/Frameworks/R.framework/Resources/library/rJava/jri/JRI.jar.
This automatically appears under the -cp tab in the run configuration.
Also, the run configuration requires a program argument: --save, --no-save or --vanilla.
Chances are it's not finding jri.dll or R.dll. If you see nothing, not even an exception, the JVM is crashing. Look for files like hs_pid* which should tell you which library is the culprit.
I have found this question in my own struggles with R on Windows, although on Linux it just worked.
I too found I was getting "Creating Rengine (with arguments)" but nothing further.
It was finding jri.dll and R.dll, which I was able to prove:
jri.dll - deleted it from the current directory, which generated the error:
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in java.library.path.
java.lang.UnsatisfiedLinkError: no jri in java.library.path
(on copying it back, make sure to take the right 32 or 64 bit version to avoid "Can't load IA 32-bit .dll on a AMD 64-bit platform" type errors)
R.dll lives under the installation directory C:\Program Files\R\R-2.15.0\bin\x64
If the PATH is set incorrectly in the run.bat file (which it was) then you get the slightly different error
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in java.library.path.
java.lang.UnsatisfiedLinkError: [CURRENT DIR]\jri.dll: Can't find dependent libraries
With those two things set correctly (and no hs_pid* files being generated) I found the problem to be the lack of R_HOME in run.bat. Adding
set R_HOME=C:\Program Files\R\R-2.15.0\
fixed it, and now it all seems to work for me. I did not need to add --save, --no-save or --vanilla to the script. Also, it had 'runtest' hardcoded, so ./run.bat runtest2 will not DWYM.
Short answer: The Windows run.bat script was broken (whereas the Linux 'run' script was correct out of the box).
I got the same problem while working with rJava, Windows 7 64 bit.
And here is the solution.
Added -Djava.library.path="${env_var:PATH}" in eclipse -> Project -> Run As -> Run Configuration -> Arguments.
And make sure System.getProperty("java.library.path") is pointing to jri.dll
I spent lot of time on this issue, so feel free to ask any questions ;)
The below error can be due to two paths not set, one is r.dll not found or/and jri.dll not found. Make sure system path includes for 32 bit systems
%R_HOME%\bin;%R_HOME%\bin\i386;%R_HOME%\library\rJava\jri\i386
Also make sure install.packages("rJava") plugin is installed from R console
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in java.library.path.
java.lang.UnsatisfiedLinkError: no jri in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at org.rosuda.JRI.Rengine.<clinit>(Rengine.java:19)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:65)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:62)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:62)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:159)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at com.acumetric.crux.analysis.StatisticCalculator.<init>(StatisticCalculator.groovy:15)

Resources