How to create an R package nested in git directory

耗尽温柔 提交于 2019-12-11 07:20:08

问题


I used to be able to build my R packages within my github repo, but the devtools functions have been deprecated and replaced with new functions that won't allow me to do this anymore.

I was previously using devtools::setup('NewPackage', check=FALSE) in my directory /home/User/NewPackage/, to create my R package /home/User/NewPackage/NewPackage

The new alternative gives the following error

usethis::create_package('NewPackage')
#New project 'NewPackage' is nested inside an existing project '/home/User/NewPackage/'
#This is rarely a good idea. Do you wish to create anyway?
#1: Negative
#2: I agree
#3: No way

I had automated my package creation, but this new function breaks the code in all of my packages.

I have posted this as a bug https://github.com/r-lib/usethis/issues/553

But I am still looking for a work around or any way to automatically submit I agree?

Hidden Files

There are also hidden files, such as .Rd2pdf12059, in my /home/User/NewPackage/ directory

Sloppy Fix

Until this is fixed, I have just copied the old devtools source code and removed what I didn't like.


回答1:


Not the cleanest way of doing things, but you could use testthat::with_mock to trick check_not_nested:

testthat::with_mock(
  check_not_nested = function(path, name) return(),
  usethis::create_package('NewPackage2'),
  .env = "usethis"
)


来源:https://stackoverflow.com/questions/53819291/how-to-create-an-r-package-nested-in-git-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!