Expected package behavior when I use `devtools::load_all` but when I use `devtools::install` and `library()` the package functions are not available

Hi everyone,

This is probably a stupid question.

I have been developing a package and everything works as expected on my machine (actually in two different machines). I can use the package when I use devtools::load_all function, it passes all tests, checks and it builds without any issues.

However, when I use devtools::install or try to install the package from the repository and load it to memory using library, the package functions on the R folder are not available.

I don't use "." in any of the function names and everything was done following the workflow described on https://r-pkgs.org/.

I have changed the name of the package before, but I can't find any remains of the old name on the repository.

Thank you for your help!

The big difference between devtools::load_all() and attaching a package to the search path with library() is that load_all() exports all the package functions. This is really convenient for rapid development. But when you install your R package and then attach it with library(), only the exported functions are available.

Some questions:

  1. Are you using roxygen2? If yes, are you using the @export tag?
  2. What is in your NAMESPACE file? Does it list the functions you want to use?
  3. What do you see when you run the following? Replace myPkg with the name of your R package. This will list all the exported functions.
    library(myPkg)
    ls("package:myPkg")
    

Thank very much for your help.

Since I was using roxygen2, the @export tag was missing. Adding it in the roxygen comments solved the problem.

Thanks again!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.