r-lib / remotes

Install R packages from GitHub, GitLab, Bitbucket, git, svn repositories, URLs
https://remotes.r-lib.org/
Other
336 stars 153 forks source link

install_github() failed by LazyData: true and git-lfs #637

Closed dan9401 closed 3 years ago

dan9401 commented 3 years ago

Hi, we had an install error when running devtools::install_github("braverock/FactorAnalytics"):

* installing *source* package ‘FactorAnalytics’ ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
Warning: file ‘StockReturns.rda’ has magic number 'versi'
  Use of save versions prior to 2 is deprecated
Error in load(zfile, envir = tmp_env) : 
  bad restore file magic number (file may be corrupted) -- no data loaded
ERROR: lazydata failed for package ‘FactorAnalytics’

The error is triggered by LazyData: true when installed from remote, and only seems to occur in repos with git-lfs objects, see carlanetto/M4comp2018#1 and braverock/FactorAnalytics#47.

devtools::install_github("braverock/FactorAnalytics") works when LazyData: true is removed from DESCRIPTION, we can also clone and build from local source without error.

Thanks.

jimhester commented 3 years ago

I think this is related to when the data files are fetched via git-lfs, perhaps you need to avoid using LazyData: true in these cases.

I don't think there is anything we could do in remotes to change this unfortunately.

Perhaps you could open an issue at https://community.rstudio.com and see if other community members have advice on best practices when using git-lfs?

braverock commented 3 years ago

It simply isn't true that there is "nothing you could do" in remotes. remotes should support 'git-lfs clone' just like it supports 'git clone'. LFS is the recommended way to support binary files in git, it isn't a "niche" solution.