[R-SIG-Mac] Installing Mac packages from a directory of .tgz files

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Jan 15 10:21:12 CET 2011


On Sat, 15 Jan 2011, Berend Hasselman wrote:

>
> On 15-01-2011, at 07:39, Murray Jorgensen wrote:
>
>> Well, still no responses, but I'm further along the trail. I decided that I must need that 'PACKAGES' file so I went back to CRAN and got it, and placed it in my /Applications/tgz12.1/ folder.
>>
>> This time with 'Other Directory URL' as 'files:///Applications/tgz12.1/' I at least got the Package list populated in the 'Repository Version' column.
>>
>> I selected all and clicked 'Install Selected' to no obvious result, 
>> although maybe I was too impatient. Then I tried again selecting 
>> only the first package 'abc' but still it seems without response.
>
>
> First of all, if you are trying to install from a local repository 
> there are specific and detailed requirements. See page 21-22 of the 
> R-admin.pdf manual under heading "Setting up a package repository".

Yes, but you don't actually need to set up a repository locally: 
provided you have a PACKAGES file you can use contriburl= in 
install.packages (and as I read it, as 'Other Directory URL').

You can even re-generated a PACKAGES file by cd-ing to the packages 
directory and using

tools::write_PACKAGES('.', type="mac.binary")

but the advantages of using a PACKAGES file+install.packages 
(installing in the right order, picking up dependencies) are bigger 
for source packages and a complete local repository.

> Second, there is no need to place the .tgz files in a folder in /Applications.
> Also highly undesirable since /Applications is for applications and a system folder.
>
> I have never installed from downloaded files so I may be completely wrong.
> I have tested my recipe by downloading foreach_1.3.0.tgz and doing as described below (except that I installed the stuff in my personal R library).
>
> Place the  .tgz files (mac binary package files) in a directory in your user tree.
> For example ~/Temp/R
>
> Start R.app and set the above directory as the working directory (menu Misc, Change Working Directory or with setwd("~/Temp/R").
>
> Then for informative purposes do list.files() to check if all went well. You should see a list of the files you placed in that directory.
>
> Now enter .libPaths() to see in which slot the main R library is 
> located (Look for 
> "/Library/Frameworks/R.framework/Resources/library"; for me it's in 
> slot 2).
>
> Assume you want to install package foreach_1.3.0 (file foreach_1.3.0.tgz) then enter the following command in R.app
>
> install.packages(pkgs=c("foreach_1.3.0.tgz"),lib=.libPaths()[2],repos=NULL)

No c() is required for a single character string.  And you normally 
want to install into the first library tree, not into R's own tree, 
but if you do want the latter it is simply lib=.Library.

> Repeat for other packages ( you can also set pkgs=c("pkg1.tgz", "pkg2.tgz",...) )

Or simply (untested)

install.packages(dir('.', pattern="tgz$"), repos=NULL)

> good luck
>
> Berend

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-SIG-Mac mailing list