Reputation: 630
I've been writing a lot of code for my personal use and finally reached a point where I realised I should really be including this all in a package which I can load in instead of copy and pasting it in each time.
I followed the following tutorial for the creation of a basic package.
https://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/
As far as I can tell everything went well with the actual creation element. Here are screenshots of the result:
The cats folder:
The /cats/R folder
The /cats/man folder
The problem comes when I want to run the line:
install("cats")
When I try to do that I get the following error:
Installing cats
"C:/PROGRA~1/R/R-33~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL "/Documents/cats" --library="C:/Users/Aodhán/Documents/R/win-library/3.3" --install-tests
* installing *source* package 'cats' ...
Warning in file(file, if (append) "a" else "w") :
cannot open file 'C:/Users/Aodhán/Documents/R/win-library/3.3/cats/DESCRIPTION': No such file or directory
Error in file(file, if (append) "a" else "w") :
cannot open the connection
ERROR: installing package DESCRIPTION failed for package 'cats'
* removing 'C:/Users/Aodhán/Documents/R/win-library/3.3/cats'
Error: Command failed (1)
This error happens for my own package, but it also happens if I run the command:
devtools::install_github("klutometis/roxygen")
Any advice would be appreciated.
EDIT: Could it be that my username contains the character á in it?
EDIT 2:The DESCRIPTION file is:
Package: cats
Title: What the Package Does (one line, title case)
Version: 0.0.0.9000
Authors@R: person("First", "Last", email = "[email protected]", role = c("aut", "cre"))
Maintainer: Aodhán O'Leary
Author: Aodhán O'Leary [aut, cre]
Description: What the package does (one paragraph).
Depends: R (>= 3.3.1)
License: What license is it under?
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
Sys.getenv("R_HOME")
returns "C:/PROGRA~1/R/R-33~1.1"
Sys.getenv("R_LIBS_USER")
returns "C:\Users\Aodhán\Documents/R/win-library/3.3"
Sys.getenv("R_HOME")
returns "C:\Users\Aodhán\Documents"
devtools::build("cats")
creates "cats_0.0.0.9000.tar.gz"
install.packages("../cats_version.tar.gz")
returns the same error as above
Note: This is on a Win10 machine, using R 3.3.1, which I apologise for not mentioning up top. I was quite tired when writing the post yesterday.
Edit 3: Here's the result of using the following commands: R CMD build cats
followed by R CMD check cats
00check:
- using log directory 'C:/Users/Aodhán/Documents/cats.Rcheck'
- using R version 3.3.1 (2016-06-21)
- using platform: x86_64-w64-mingw32 (64-bit)
- using session charset: ISO8859-1
- checking for file 'cats/DESCRIPTION' ... OK
- this is package 'cats' version '0.0.0.9000'
- package encoding: UTF-8
- checking package namespace information ... OK
- checking package dependencies ... OK
- checking if this is a source package ... OK
- checking if there is a namespace ... OK
- checking for .dll and .exe files ... OK
- checking for hidden files and directories ... NOTE Found the following hidden files and directories: .gitignore These were most likely included in error. See section 'Package structure' in the 'Writing R Extensions' manual.
- checking for portable file names ... OK
- checking whether package 'cats' can be installed ... ERROR Installation failed. See 'C:/Users/Aodhán/Documents/cats.Rcheck/00install.out' for details.
- DONE
Status: 1 ERROR, 1 NOTE
00install.out
- installing source package 'cats' ...
Warning in file(file, if (append) "a" else "w") : cannot open file 'C:/Users/Aodhan/Documents/cats.Rcheck/cats/DESCRIPTION':
No such file or directory
Error in file(file, if (append) "a" else "w") : cannot open the connection
ERROR: installing package DESCRIPTION failed for package 'cats'
- removing 'C:/Users/Aodhán/Documents/cats.Rcheck/cats'
Upvotes: 2
Views: 4057
Reputation: 1335
I've run into this problem recently (R version 3.5.2) on two different computers. I don't have the full, exact error message right now, but it contained the following two snippets:
Error in writeLines(paste0(c(out[is_not_empty]), eor), file, useBytes = useBytes) :
(converted from warning) invalid char string in output conversion
and
ERROR: installing package DESCRIPTION failed for package
The problem, I believe, was the existence of special characters in my .Rprofile
file. I'd been meaning to get rid of that file anyway (for the sake of reproducibility), and doing so fixed the problem.
To do this in R, the code below will (1) copy your .Rprofile
and save it as .Rprofile-old
(in case you want to use/restore it later on) and then (2) delete your .Rprofile
.
## copy backup of .Rprofile
file.copy("~/.Rprofile", "~/.Rprofile-old")
## delete .Rprofile
unlink("~/.Rprofile")
Once you've run the above code, restart R and the problem will [hopefully] be fixed!
Upvotes: 1
Reputation: 630
The problem was the special character in my name, á. When I put it in the C:\ directory and ran R CMD build cats
and R CMD check cats
it passed that error (though there was an error later on with the pdf - I'll see if I can resolve that myself).
I'll try and post this as a bug. Moderately annoying. Should have thought of that test earlier.
Upvotes: 2
Reputation: 36
Installing source package.. It is important to specify repo and type
Upvotes: 0