devtools load_all vs install

I was putting the finishing touches on the README of a new package when I entered unfamiliar territory. I have code that runs smoothly after devtools::load_all(), but when I devtools::install() and call library(package_name), an error is thrown on the same code. I know there's a difference between load_all and install, but I thought after installing the working dev code, it would behave properly. What are some possible reasons for this mixup?

3 Likes

One possible reason is that with devtools::load_all() you make all the functions in your package available to the current R session, even those which are not exported via NAMESPACE. With library(package_name) you only get those functions that are exported via NAMESPACE.

2 Likes

Hmmm, I exported every single function and method in the package with no luck. Works w/ load_all, not with install + library(package).

In that case it might be a good idea to provide us with additional information. For example, what error message do you get? In addition, it makes sense to try and reduce the problem towards a minimal example. Keep in mind that library(package_name) is The Truth which devtools::load_all() "roughly simulates".

2 Likes

Thanks Ralf, I'm now using load_all(export_all = FALSE) and getting matching errors, so I feel like I'm getting closer.

1 Like

I have a similar problem with devtools::load_all() vs devtools::install

works:

devtools::load_all(path = "~/code/r_mp3_files")  

but this fails:

devtools::install(pkg = "~/code/r_mp3_files")

#> Error: HTTP error 401.
#> Bad credentials
#>
#> Rate limit remaining: 55/60
#> Rate limit reset at: 2020-02-09 06:43:22 UTC
#>
#>