Closed wlandau closed 7 months ago
The root can either be the package root directory or within the packet directory.
This is a weird error we thought we had solved (ISSUE #204, PR #210), but apparently not. I will investigate.
I think I sorted out what is going on - it is supposed to throw an error if the function is called outside of a package/packet.
However, because the workshop is a project overall, it finds and sets the root to the workshops root. When it searches for the config, it finds all the various config files within the workshop, and lists all of them. Which leads to your error, @wlandau, because the path gets sent to create_item()
(a helper function under valtools).
reprex code:
library(valtools)
library(testthat)
test_that("Informative error when inside an Rproj, but packet or package is nested in a subfolder", {
withr::with_tempdir({
quiet <- capture.output({
usethis::create_project("test_project",open = FALSE)
vt_create_packet("test_project/example_packet",
target = "example.package",
open = FALSE)
vt_create_packet("test_project/example_packet2",
target = "example.package",
open = FALSE)
})
withr::with_dir(new = "test_project", {
expect_error(
vt_find_config(),
paste0(
"Could not find root directory. ",
"Is your working directory inside a package, validation packet, or project?\n"
),
fixed = TRUE)
})
})
})
@wlandau, would it have been useful for an error to point to the fact that you were in a situation of nested projects, and you needed to change directories? I have a PR opened in #217 that makes it so it would give an error like below:
Error: Nested projects with validation infrastructures exist. Set the working directory to one of:
- `setwd("r_pharma_validation")`
- `setwd("example_packet2")`
Yes, that definitely would have helped. I was confused about what working directory I needed, especially since the workshop example was not part of an R package.
valtools
seems to require the working directory to be the root of the validation file space, not the root of the package. If I try this command, but withname
equal tofile.path("r_pharma_validation", "req1.md")
and my working directory one level up, I get an error and warnings. This took a few minutes to debug during the workshop today.