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

Make packages loaded by load_all() children of global environment #125

Closed
wch opened this issue Aug 3, 2012 · 1 comment
Closed

Make packages loaded by load_all() children of global environment #125

wch opened this issue Aug 3, 2012 · 1 comment

Comments

@wch
Copy link
Member

wch commented Aug 3, 2012

Objects loaded via load_all() behave somewhat differently from loading those loaded with library().

With load_all(), the package environment is not a child of the global environment. But with library(), it is a child of the global environment.

This code will illustrate:

# This prints all parent environments, until it hits top (emptyenv)
printenvs <- function(e = parent.frame(), n = 100) {
  cat(str(e, give.attr=F))
  i <- 1
  while(i < n) {
    if (identical(e, emptyenv()))
      break

    e <- parent.env(e)
    cat(str(e, give.attr=F))
    i <- i+1
  }
  cat("\n")
  return(e)
}


library(ggplot2)
debugonce(qplot)
qplot()
printenvs()
# <environment: R_GlobalEnv> is a parent


# === Might need to restart R to do this ===
library(devtools)
load_all('.')
debugonce(qplot)
qplot()
printenvs()
# <environment: R_GlobalEnv> is not a parent
@wch
Copy link
Member Author

wch commented Aug 10, 2012

Implemented in #126.

@wch wch closed this as completed Aug 10, 2012
@lock lock bot locked and limited conversation to collaborators Sep 19, 2018
jimhester added a commit that referenced this issue Jun 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant