Skip to content
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

Error in loadNamespace(Name) : There is No Package Called 'here' | Credibly Curious #46

Open
utterances-bot opened this issue Jul 30, 2020 · 10 comments

Comments

@utterances-bot
Copy link

Error in loadNamespace(Name) : There is No Package Called 'here' | Credibly Curious

https://www.njtierney.com/post/2020/05/29/there-is-no-pkg/

Copy link

Thanks to you for this post.

@njtierney
Copy link
Collaborator

No worries!

Copy link

leahymr commented Apr 5, 2021

Nick, I'm getting this error when attempting to knit an RMarkdown file. If I run library ("papaja") in the console, the library is loaded. But the same command in the .Rmd file causes Error in loadNamespace(name) : there is no package called ‘papaja’. Do you have suggestions on how to debug this?

Copy link

leahymr commented Apr 5, 2021

I can add that I am able to execute render("file.Rmd") from the RStudio command line, so all the components are there, just knitr can't find papaja. I compared .libPaths() from the RStudio command line and from a code block within the .Rmd file, and they give the same set of paths, in the same order.

I am running Mac OS 14.6 with R 4.0.4 and RStudio 1.4.1106.

@njtierney
Copy link
Collaborator

Hi @leahymr - that sounds a bit tricky, do you have an example I could look at on github, or elsewhere? Happy to take a look and see if I can help.

@leahymr
Copy link

leahymr commented Apr 8, 2021

@njtierney , I have posted my code at github.com:leahymr/papaja-problems.git.
Two .Rmd files: Simple.Rmd is trivial, Default.Rmd is a minimized version of the default papaja .Rmd file.

Since I can render("Default.Rmd") but knitting Default.Rmd fails, it must be a difference in the knit environment.
I generated what I know to generate and put them in the Render and RMarkdown files.

Are there some other commands that I should try to find differences?

Oh, I have the following commands in my .Rprofile file:
.libPaths("/usr/local/lib/R/site-library")
.First <- function() {
trace(base:::loadNamespace, quote({
if (package == "papaja")
utils::str(sys.calls())
}), print = FALSE)
utils::sessionInfo()
}

and my .Renviron file:
R_LIBS_USER="/Users/leahym/Library/R/4.0/library"

Thanks.

Copy link

leahymr commented Apr 12, 2021

@njtierney, I found my problem. As soon as I commented out the .libpaths() command in the .Rprofile file, the problem went away.

Having a .libpaths() command caused two problems:

  1. I could not knit a papaja document
  2. I could not knit an RMarkdown > Shiny > Shiny Document

Perhaps this note will help others who get the Error in loadNamespace(name) and the other explanations don't fit.

@njtierney
Copy link
Collaborator

@leahymr I'm so happy to hear you've solved the issue! Thank you for documenting it, and sorry I didn't get back to you sooner.

Copy link

leahymr commented Apr 12, 2021

For the record, the correct way to do what I was trying to do (add a site directory to the library search path) would be to put the string R_LIBS_SITE="/path/to/site-library" (separate multiple directories with colons) in the file $R_HOME/etc/Renviron.site or the string R_LIBS_USER="/path/to/user-library" in the file $HOME/.Renviron.

My problem was I overwrote the .libPaths() value, causing R to no longer know where the rest of the libraries were installed.

For full details, see
https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/Startup

Copy link

install.packages("here")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants