1

I am running cmd-line R (version 3.3.1) without any problem. Installing any package locally from either CRAN or GitHub (i.e. for the user running the session) is ok.

However, in order to install pagkages globally, I use:

$ sudo su -l -c "/usr/bin/R -e \"install.packages('package-name', repos='https://cran.rstudio.com/')\""
/usr/bin/R: line 8: uname: command not found

Following an R session is started and:

> install.packages('package-name',repos='https://cran.rstudio.com/')

is correctly executed inside the R session.

Package components are correctly downloaded and after the last one has finished downloading, I get the 16 identical instances of:

/usr/lib/R/bin/R: line 8: uname: command not found
/usr/lib/R/bin/R: line 143: exec: sh: not found

followed in the end by

The downloaded source packages are in
    ‘/tmp/RtmpqL1osU/downloaded_packages’
There were 16 warnings (use warnings() to see them)
> 
> 
sh: 1: rm: not found

I tried this for devtools, swirl, ..., all packages I want to install for all users on the platform.

Installation from CRAN in a local library, i.e. for a given user, gives no trouble. Can anyone suggest how I should proceed ? Thanks.

Cbhihe
  • 511
  • 9
  • 24

2 Answers2

0

Well it seems that /usr/bin is not in your $PATH when you use sudo ($PATH from /etc/sudoers is used by sudo, etc/profile is not loaded.).

One workaround is to use su - and then execute the installation (etc/profile should be loaded). Another solution might be to add /usr/bin to the $PATH in your sudo statement.

Aeck
  • 543
  • 7
  • 11
  • Thanks Aeck, however `/usr/bin` is in my `$PATH` env-variable in `/etc/sudoers` and running with `- ` instead of `-l` produces the exact same faulty result... – Cbhihe Sep 14 '16 at 22:50
0

I just spent well over an hour trying to troubleshoot this issue so I'm going to cross-post a solution from RStudio that worked for me (This post is easier to find on Google).

I was having unrelated issues with reticulate so I tried to start with a clean-slate. After completely removing RStudio/r-base-core from Ubuntu 18, then reinstalling, I noticed the issue from above:

/usr/lib/R/bin/R: line 8: uname: command not found
/usr/lib/R/bin/R: line 143: exec: sh: not found

The problem

I had a .Renviron file sitting in my home directory from a previous installation. It had GITHUB_PAT, GITHUB_USERNAME and a PATH (to python). Once I removed this I was able to install packages again.

halfer
  • 19,824
  • 17
  • 99
  • 186