I'm developing a package in RStudio using devtools, and while I can install the package on my machine using devtools::install(), and R CMD INSTALL package.tar.gz, I'm having problems packaging it for others.
Running devtools::build() and devtools::install_local() on the resultant .tar.gz returns the following issue:
devtools::install_local("../ecsgR_0.2.0.tar.gz")
Error in git2r::discover_repository(path, ceiling = 0) :
Error in 'git2r_repository_discover': The.gitfile at '/home/stuart/repos/ecsgR_0.2.0.tar.gz' is malformed
I also get the same issue if I build to source with devtools::build(binary=TRUE), although I don't have any native code in my package so this shouldn't be an issue. If I manually extract the .tar.gz and run devtools::install_local("../path/to/extractedfolder") it installs without any issue. load_all() works fine, and check() returns no errors, notes, or warnings.
I'm getting the same behaviour under Windows 8 (running R 3.3.1) and Fedora 22 (running R 3.3.0), both using devtools 1.12.0. I am using git for version control, I'm using a private git server rather than github however. I've run git clean and it says my repository is fine.
If it'd help I can try to edit my code to an extent where I can upload it for a working example.
I'm also having the same problem on windows 7 Pro and Windows 10, I'll try and see if the same occurs on Ubuntu but I suspect it will.
Here's a reproducible example, taken directly from the devtools documentation of install_source :
dir <- tempfile()
dir.create(dir)
pkg <- download.packages("mistral", dir, type = "source")
install_local(pkg[, 2])
I have tried the above using R 3.3.1 (win 7 Pro and win 10) and 3.2.5 (win 10). Given @stulacy 's comments, I don't think it's a matter of platform or R version.
I am volunteering on helping in Mooc, and we have had a couple of reports of this in the past week as well, but it seems to be a tiny percentage of people (not me so I have nothing specific to add about the cause)
Same issue:
Windows 8.1
devtools 1.12.0
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 3.1
year 2016
month 06
day 21
svn rev 70800
language R
version.string R version 3.3.1 (2016-06-21)
nickname Bug in Your Hair
I am a learner in Mooc from China. Because China web control I have to chose install_local(). However it does not work. Any advice?
install_local(file.choose())
Error in git2r::discover_repository(path, ceiling = 0) :
Error in 'git2r_repository_discover': The .git file at '/Users/XXXXXX/Desktop/statsr-master.zip' is malformed
Hydebutterfly, In every case of this I have heard about, the manual extraction workaround found by stulacy (above) works- download the file from its archive on github, decompress the zip compressed file yourself so you have a folder with the package parts in it, and then do
install_local("path/to/the/decompressed/folder")
using the path to your decompressed folder.
thanks a lot @thoughtfulbloke, I tried this and it works perfectly
@thoughtfulbloke I tried but it starts to look for all the dependency packages... Does that mean I'll have to remove the dependency package in description file every time I want to install a package?
This is really a nasty issue and I'll have to spend 10x more time on updating my packages :S
There is really no reason to use install_local() other than convenience. If you are trying to install a package from a folder use install() directly. If you are trying to install a package from a compressed file just use R CMD INSTALL.
I changed from install_local to install() and it worked for me as suggested by @jimhester Thanks for the advice.
My code as example:
library(devtools)
devtools::install("/Users/caiomsouza/git/github.com/SparkR-pkg/pkg/")
Didn't work for me:
devtools::install("/Users/dan/work/foo")
Installing foo
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet \
CMD INSTALL '/Users/dan/work/foo' \
--library='/Library/Frameworks/R.framework/Versions/3.2/Resources/library' --install-tests
R.version.string
[1] "R version 3.2.4 (2016-03-10)"
OS X 10.12.1
this works for me
install_remote=function (path, ..., force = FALSE, quiet = FALSE){
remotes <- lapply(path, devtools:::local_remote, subdir = NULL)
invisible(vapply(remotes,FUN = function(remote){
stopifnot(devtools:::is.remote(remote))
bundle <- devtools:::remote_download(remote, quiet = quiet)
on.exit(unlink(bundle), add = TRUE)
source <- devtools:::source_pkg(bundle, subdir = remote$subdir)
on.exit(unlink(source, recursive = TRUE), add = TRUE)
devtools::install(source, ..., quiet = quiet)
}, FUN.VALUE = logical(1)))
}
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/
Most helpful comment
Hydebutterfly, In every case of this I have heard about, the manual extraction workaround found by stulacy (above) works- download the file from its archive on github, decompress the zip compressed file yourself so you have a folder with the package parts in it, and then do
install_local("path/to/the/decompressed/folder")
using the path to your decompressed folder.