0

For some reason, I could not install the rJava package without root privilege (using sudo R and then install.packages('rJava')). It should have solved my problem, however I can only use this package when launching R with sudo R. If I launch it without sudo, R will act as if this package is not installed.

I tried looking at /usr/local/lib/R/site-library, every package belongs to my user and group "staff" except this one, that belongs to root and staff. The rights for every package are rwxrwxr-x and I am in group staff, so I should have all the permissions I need. In addition, I tried changing the owner of the rJava folder to my user and it didn't change anything. Do anybody have any idea why rJava is not recognized if I start R without sudo? Thanks!

milbil
  • 1
  • 1
  • 1
    have you tried installing via `sudo apt-get install r-cran-rJava`? – DunderChief Oct 27 '15 at 16:09
  • 2
    Almost: all package names are lowercase: `sudo apt-get install r-cran-rjava` -- a package I have been maintaining for a decade now _precisely_ because installation can be a stumbling block for new users. – Dirk Eddelbuettel Oct 27 '15 at 16:31
  • @dirkeddelbuettel -- Oops, you're right. Although `r-cran-rJava` did in fact install the package. `R-CraN-RjAvA` works too. (Ubuntu 15.04) – DunderChief Oct 27 '15 at 17:20
  • Actually I did it. However, I don't know why but r still tries to (and fails to without su rights) install rJava when I try to install glmulti with install.packages(). – milbil Oct 27 '15 at 19:02
  • @milbil -- Do you get an error when you run `library(rJava)`? If so, what is it? – DunderChief Oct 27 '15 at 20:03
  • @milbil -- Also, what version of java do have installed `java -version` – DunderChief Oct 27 '15 at 20:43
  • @DunderChief I get Error in library(rJava) : aucun package nommé ‘rJava’ n'est trouvé (which means no package named 'rJava' was found) for the version of java: ``$ java -version java version "1.7.0_79" OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6- 1~deb8u1) OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)`` – milbil Oct 27 '15 at 23:05
  • Check `.libPaths()` when running R as sudo and without. You want to install into a directory that is on both paths otherwise the one or another won't see it. – Simon Urbanek Dec 09 '15 at 15:34

2 Answers2

0

I also had issues installing rJava so I'll outline the steps I took to fix it even though it may be specific to my system. There's at least a chance it will work for you too.

Remove rJava and openjdk:

sudo apt-get purge r-cran-rjava
sudo apt-get purge openjdk-7-jre

Install oracle java:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Reinstall rJava

sudo apt-get install r-cran-rjava

After that everything was hunky-dory. glmulti installed fine as well.

DunderChief
  • 726
  • 4
  • 7
  • I tried it put it still doesn't work unless I use sudo R. install.packages also fails with the same error. – milbil Oct 27 '15 at 23:38
  • @milbil -- could you try `remove.packages('rJava')` as root user prior to reinstalling via `apt-get`. Just throwing out guesses now. – DunderChief Oct 28 '15 at 00:08
0

Try unsetting the JAVA_HOME environmental variable before starting R:

unset JAVA_HOME
Gon
  • 11
  • 1