Skip to content

Commit c895ad1

Browse files
committed
Better proj_get error message
1 parent 411a02a commit c895ad1

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

R/proj.R

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,21 @@ proj_find <- function(path = ".") {
3030
#' @keywords internal
3131
#' @export
3232
proj_get <- function() {
33-
if (is.null(proj$cur)) {
34-
stop("No active project found", call. = FALSE)
33+
if (!is.null(proj$cur)) {
34+
return(proj$cur)
3535
}
36-
proj$cur
36+
37+
# Try current wd
38+
proj_set(".")
39+
if (!is.null(proj$cur)) {
40+
return(proj$cur)
41+
}
42+
43+
stop(
44+
"Current working directory, ", value(normalizePath(".")), ", ",
45+
" does not appear to be inside a project or package.",
46+
call. = FALSE
47+
)
3748
}
3849

3950
#' @export

0 commit comments

Comments
 (0)