简体   繁体   中英

R install.package fails on data-raw file not found

I am building an R package, with some associated data. I have created a data-raw folder using usethis:: functions, put various txt fies there, and built out R code to generate the.rda/Rdata files. I have used the use_data() function to generate the.rda and Rdata files and these I can see in /data.

I can retrieve these objects using load_all().

I then build a source package, which generates a compressed-tar-ball.

Finally I attempt to install that tar-ball/package in another project and get:

 devtools::install_local("/home/fred/Rprojects/evidently/evidently_0.0.2.1.tar.gz")
✓  checking for file ‘/tmp/Rtmp53yb8S/remotes2eaf7a4fc2cb/evidently/DESCRIPTION’ ...
─  preparing ‘evidently’:
✓  checking DESCRIPTION meta-information
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘evidently_0.0.2.1.tar.gz’
   
Installing package into ‘/home/rob/R/x86_64-pc-linux-gnu-library/4.0’
    (as ‘lib’ is unspecified)
    * installing *source* package ‘evidently’ ...
    ** using staged installation
    ** R
    ** data
    *** moving datasets to lazyload DB
    ** byte-compile and prepare package for lazy loading
    Error : **'/tmp/Rtmp0PbObQ/R.INSTALL391126f5cc7c/evidently/data-raw/TPBULET-A.txt' does not exist.**
    Error: unable to load R code in package ‘evidently’
    Execution halted
    ERROR: lazy loading failed for package ‘evidently’
    * removing ‘/home/fred/R/x86_64-pc-linux-gnu-library/4.0/evidently’
    * restoring previous ‘/home/rob/R/x86_64-pc-linux-gnu-library/4.0/evidently’
    Error: Failed to install 'evidently' from local:
      (converted from warning) installation of package ‘/tmp/Rtmp53yb8S/file2eaf5f6ca68c/evidently_0.0.2.1.tar.gz’ had non-zero exit status
    > 

But the file it says it is looking for is in data-raw in the package folder.

I am missing something obvious here. I would welcome suggestions on why the system is not seeing the txt file, and why it is therefore aborting the install.

This happens when you have a rogue link to the data-raw file, in a file you thought you had purged, and when it gets loaded as part of install-packages, it tries to find a file in data-raw/ that is not there in the package, because data-raw/ is not part of the package, just in the source code. So, search your files and find the forgotten bit of code. Hang head in shame.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM