user2448881
user2448881

Reputation: 311

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â

Upvotes: 20

Views: 17895

Answers (4)

F. Priv&#233;
F. Priv&#233;

Reputation: 11728

One can now use remotes::install_url() or remotes::install_local().

It installs dependencies and generates the NAMESPACE file automatically.

Upvotes: 1

Peter
Peter

Reputation: 31

I found the following link more useful: How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?

6. The package is out of date

It may have been archived (if it is no longer maintained and no longer passes R CMD check tests).

In this case, you can load an old version of the package using install_version()

library(devtools)
install_version("foobarbaz", "0.1.2")

An alternative is to install from the github CRAN mirror.

library(devtools)
install_github("cran/foobarbaz")

Upvotes: 3

polarise
polarise

Reputation: 2413

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.

Upvotes: 42

Christopher Neylan
Christopher Neylan

Reputation: 8272

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!

Upvotes: 4

Related Questions