6

Ubuntu 12.10 x64, R 2.15.2

I'm at a loss, I've installed R numerous times and never had the slightest problem with the install. This time however when I launch the program (either by using the GUI or by typing "R" in the terminal) I get this;

cannot find system Renviron Error : .onLoad failed in loadNamespace() for 'utils', details: call: options(op.utils[toset]) error: invalid value for 'editor'

R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R.

Error : .onLoad failed in loadNamespace() for 'utils', details:
call: options(op.utils[toset]) error: invalid value for 'editor' In addition: Warning message: package "methods" in options("defaultPackages") was not found Error : .onLoad failed in loadNamespace() for 'utils', details: call: options(op.utils[toset]) error: invalid value for 'editor' In addition: Warning message: package ‘utils’ in options("defaultPackages") was not found Error : .onLoad failed in loadNamespace() for 'utils', details: call: options(op.utils[toset]) error: invalid value for 'editor' In addition: Warning message: package ‘stats’ in options("defaultPackages") was not found During startup - Warning message: package ‘methods’ in options("defaultPackages") was not found

Nothing works, no packages are found. I've never received any training on how to use Ubuntu, but from what I can gather I am missing the recommended packages for R.

I've tried completely removing R using both the Terminal as well as Synaptics Package Manager, then re-downloading the from CRAN servers (it seems to download too fast for my internet connection) and then reinstall. Same message. I'm at a loss.

AlaskaKraska
  • 100
  • 1
  • 7
  • How are you installing R? What GUI are you referring to? Have you followed the instructions at http://cran.r-project.org/bin/linux/ubuntu/README.html? – Ista Feb 26 '13 at 14:00
  • as per the instructions on the CRAN website I added the repository for Quantal with the local mirror [link](http://probability.ca/cran/bin/linux/ubuntu) and then ran `sudo apt-get update` and then `sudo apt-get install r-base` I'm thinking maybe some dependencies are missing? – AlaskaKraska Feb 26 '13 at 23:03
  • Try uninstalling R, then `sudo rm -r /etc/R/` then re-install R. – Ista Feb 26 '13 at 23:31

4 Answers4

7

I had the same problem and setting the EDITOR environment variable solved the problem for me.

Try e.g.

EDITOR=vim R

If that works, put the line

export EDITOR=vim

at the end of your ~/.profile

EDIT: the root of the problem was that /etc/R/Renviron was not read by R. As Dirk commented on his reply,

sudo chmod 644 /etc/R/Renviron

solves the problem

Tomas Mikula
  • 6,537
  • 25
  • 39
  • 1
    Thanks for the follow-up. That is fixed in the newest Debian R packages which should propagate to CRAN as Ubuntu ports in due course too. – Dirk Eddelbuettel Feb 27 '13 at 12:21
  • Thank you very much Tomas, That worked like a charm! I was starting to worry that I would need to reinstall Ubuntu or go back to Windows on my home computer! – AlaskaKraska Feb 27 '13 at 12:55
  • @AlaskaKraska You need better debugging skills. When a single package breaks, you do not need to leave an OS. If a single version of a package fails, it can help to look at what changes were made. That would have led you to /etc/R/Renviron which I was asked to create differently -- hence the (accidentally) wrong mode. – Dirk Eddelbuettel Feb 27 '13 at 13:27
  • Great. Worked for me. – Indika K Mar 15 '17 at 03:02
  • The first part of this solution (before the EDIT) worked for me with debian KDE in kate. R was starting fine from konsole but not from the Terminal embedded into kate. Thanks – HelloWorld Aug 25 '20 at 08:25
1

The error seems to be the following :

error: invalid value for 'editor'

You can try to type the following in a terminal to know what the value of your EDITOR environment variable currently is :

echo $EDITOR

And maybe you should be able to start R from the command-line with something like :

EDITOR="" R
juba
  • 47,631
  • 14
  • 113
  • 118
  • `echo $EDITOR` doesn't print out anything in the terminal. Should I be typing anything else before? or should I be in the R directory? – AlaskaKraska Feb 26 '13 at 22:55
  • If it doesn't print out anything, it should be because the variable is not set. But then it shouldn't be the problem that prevents R to start. I presume that `EDITOR="" R` doesn't work either ? – juba Feb 26 '13 at 23:25
1

But it starts to get dicy before it gets to editor -- it seems like it fails to load your saved environment. Can you try

 R --no-restore-data

or even

 R --vanilla

Needless to say, it works for me and the only configuration change made was in the Java stack (see the Changelog file).

There is a dedicated list r-sig-debian for the Debian and Ubuntu packages where you'd get me (Debian packages), Johannes (Debian backports, available via CRAN) and Michael (Ubuntu builds, available via CRAN). I tend to run Michael's packages on my Ubuntu machines and have not had an issue.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • Both `R --no-restore-data` and `R --vanilla` produce the same results as before. I've tried removing R and reinstalling it, but it doesn't do anything either. I'm at a loss for what to do. – AlaskaKraska Feb 26 '13 at 22:53
  • 1
    It may be http://bugs.debian.org/701774 which I just fixed: try `sudo chmod 644 /etc/R/Renviron`. Otherwise: dunno. Works on all my Ubuntu machines. – Dirk Eddelbuettel Feb 27 '13 at 01:41
  • I'm not sure if it was you or Tomas who answered first with the `sudo chmod 644 /etc/R/Renviron` fix, but it worked, so Thank you! – AlaskaKraska Feb 27 '13 at 12:57
0

I encountered this problems after I insall R and RStudio too.Both of them apear to have problems same as yours. I can't find the .Renviron in /etc/R.Then I search the Internet and find out I should use this file to set envirenments for my R. So all I need to do is new a ".Renviron" file and write it correctly. Fortunatelly I find a file named "Renviron.site" in /etc/R and inside it I find a few lines of comments :

   # ## Example .Renviron on Windows
   # R_LIBS=C:/R/library
   # MY_TCLTK="c:/Program Files/Tcl/bin"……

I suppose this would be useful to write my .Renviron file. So I write these in terminal:

sudo gedit /etc/R/.Renviron The .Renviron file is automatically created and open by gedit.Later on I copy

R_LIBS=~/R/library

PAGER=/usr/local/bin/less

R_DEFAULT_PACKAGES='utils,grDevices,graphics,stats'

into .Renviron file and save it.And the RStudio just work normally!