Skip to content

problem setting globals in .onLoad() #3

@jcdny

Description

@jcdny

I have a package which sets some globals in the .onLoad function but when I try to load the package with devtools I get an error trying to reference the global variables within the .onLoad function itself.

simple example:

.onLoad <- function(lib, pkg, ...) {
  XX <<- "key"
  YY <<- paste(XX, "value",sep="=")
}

Produces the following error in R

$ R
> l(gmutil)
Error in paste(XX, "value", sep = "=") : object 'XX' not found

if I comment out the second line the code loads fine and XX is set in the global environment.

The package itself passes R CMD check with no errors an loads fine when installed...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions