Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR: a 'NAMESPACE' file is required

I am trying to install some R packages on a Linux machine using

R CMD INSTALL -l <ourRlibrarylocation> <path where I saved the packagename.tar.gz file>

and I see an error message:

ERROR: a 'NAMESPACE' file is required

I am using R 3.0.1. Please help, I am new to R and just downloaded these packages for customers.

One example:

 R CMD INSTALL -l /abcde/R/R-3.0.0/library /home/RFILES/PKG/UScensus2000tract_0.03.tar.gz
* installing *source* package âUScensus2000tractâ ...
ERROR: a 'NAMESPACE' file is required
* removing â/abcde/R/R-3.0.0/library/UScensus2000tractâ
like image 766
user2448881 Avatar asked Jun 19 '13 16:06

user2448881


2 Answers

According to the R documentation for writing extensions, all packages destined for version 3.0.0 and later must contain a NAMESPACE file. If you download an R package that gives you the above error, here's what you should try:

Untar the package:

tar -xvf the_package.tar.gz

Add a NAMESPACE file with the line exportPattern( "." ):

cd the_package
echo 'exportPattern( "." )' > NAMESPACE
cd ..

Re-tar the package:

tar -zcf the_package.tar.gz the_package

Try and install it again.

Hope that helps.

like image 125
polarise Avatar answered Sep 20 '22 12:09

polarise


I actually just hit the same thing when compiling R-3.0.1. It looks to be that the package version that I was using was out of date. This was for proto:

# /var/local/R-3.0.1/bin/R CMD INSTALL -l /var/local/R-3.0.1/lib64/R/library proto_0.3-9.2.tar.gz
* installing *source* package ‘proto’ ...
ERROR: a 'NAMESPACE' file is required
* removing ‘/var/local/R-3.0.1/lib64/R/library/proto’

But there was a newer version for proto (0.3-10) which worked fine:

# ../var/local/R-3.0.1/bin/R CMD INSTALL -l ../var/local/R-3.0.1/lib64/R/library proto_0.3-10.tar.gz
* installing *source* package ‘proto’ ...
** package ‘proto’ successfully unpacked and MD5 sums checked
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
   ‘proto.Rnw’
   ‘protoref.Rnw’
** testing if installed package can be loaded
* DONE (proto)

I had an older install of R (2.15), which the older proto package worked with:

# /var/local/R-2.15.0/bin/R CMD INSTALL -l /var/local/R-2.15.0/lib64/R/library proto_0.3-9.2.tar.gz
* installing *source* package 'proto' ...
** Creating default NAMESPACE file
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
   'proto.Rnw'
   'protoref.Rnw'
** testing if installed package can be loaded

It looks like the older version of R actually creates the missing NAMESPACE file, but the new version bails. Hope this helps you!

like image 22
Christopher Neylan Avatar answered Sep 21 '22 12:09

Christopher Neylan