-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wrong default file path in run_dev()
documentation, file path hard coded
#886
Comments
Hi @Teebusch, |
Make sure to start from the https://github.com/ThinkR-open/golem/blob/dev/R/run_dev.R |
Thanks a lot, this is indeed a typo in the documentation. As far as I can tell from re-reading the code, if you supply another path to a dev file (say, That being said, I would suggest moving to a clearer option where the param has the default value Let us know if you feel like doing a PR. Cheers, |
I'm thinking about something |
@ColinFay it does use the user-supplied value to build a file path (ln. 25) but then reads the content of try_dev <- file.path(
pkgload::pkg_path(),
file
)
if (file.exists(try_dev)) {
run_dev_lines <- readLines("dev/run_dev.R") # this right here
} else {
stop("Unable to locate dev file")
} |
@VincentGuyader Sounds like a good idea. In addition, the function does not always check if the file exists before trying to read it. Only if if (pkgload::is_dev_package(pkg)) {
run_dev_lines <- readLines( # immediately tries to read file w/o checking existence
file.path(
pkgload::pkg_path(),
file
)
)
} else {
# ...
} |
Here's a suggestion with some additional changes. I'll make a PR later. [Edit: using
#' Run dev file
#'
#' @param file File path to dev file. Defaults to `dev/run_dev.R`.
#' @inheritParams add_module
#'
#' @export
#'
#' @return Used for side-effect
run_dev <- function(
file = "dev/run_dev.R",
pkg = get_golem_wd()
) {
f <- here::here(pkg, file)
if (!file.exists(f)) {
stop("Unable to locate dev file")
} else {
dev_lines <- readLines(f)
eval(parse(text = dev_lines))
}
} |
That sounds awesome 👏 Just a note: there is no need to here::here() the path, as get_golem_wd() is already returning the output of here::here() :) |
- use path constructed from 'file' argument instead of hard code "dev/run_dev.R" - improve error message on failure Refs: ThinkR-open#886
- use path constructed from 'file' argument instead of hard code "dev/run_dev.R" - improve error message on failure Refs: ThinkR-open#886
…ev.R` (#1050) * fix: user supplied 'file'-argument works correctly - use path constructed from 'file' argument instead of hard code "dev/run_dev.R" - improve error message on failure Refs: #886 * tests: improve test-covr. of run_dev.R form 0% to 100% - add test for default 'file' argument - add test for user supplied 'file' argument where - run_dev.R renamed to run_dev2.R - path to run_dev changed to top-level golem path - add test for error if run_dev cannot find the 'file' * docs: update docs for run_dev - give a bit more context on usage - fix some typos - use markdown highlighting consistently - add invisible return as this is a pure side-effect function
* add user supplied `file` for `run_dev()` & make covr. 100% for `run_dev.R` (#1050) * fix: user supplied 'file'-argument works correctly - use path constructed from 'file' argument instead of hard code "dev/run_dev.R" - improve error message on failure Refs: #886 * tests: improve test-covr. of run_dev.R form 0% to 100% - add test for default 'file' argument - add test for user supplied 'file' argument where - run_dev.R renamed to run_dev2.R - path to run_dev changed to top-level golem path - add test for error if run_dev cannot find the 'file' * docs: update docs for run_dev - give a bit more context on usage - fix some typos - use markdown highlighting consistently - add invisible return as this is a pure side-effect function * core update README --------- Co-authored-by: Ilya Zarubin <[email protected]>
Hi folks...just noting that this is still an issue in the currently released CRAN version of the package 0.4.1. When is a new version going to be released? |
@odysseyjake currently working on a new release, so I suppose in november :) |
That being said, as it is now in the dev branch, I'll close this issue :) |
The
run_dev()
docstring says that the default path for the project'srun_dev.R
file isR/run_dev()
,golem/R/run_dev.R
Line 3 in 709a382
but the default is actually set to
dev/run_dev()
:golem/R/run_dev.R
Line 14 in 709a382
If the user supplies a
file
argument, the function checks whether that file exists but then goes on to eval the content ofdev/run_dev.R
anywaygolem/R/run_dev.R
Line 31 in 709a382
I can't make a PR right now or test this, but I think this should fix it (assuming that the default location of
run_dev.R
is supposed to be indev
):Let me know if you agree with this solution and I will make a PR.
The text was updated successfully, but these errors were encountered: