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

UDUNITS2_XML_PATH is ignored #21

Open
JimMcL opened this issue Jan 19, 2018 · 1 comment
Open

UDUNITS2_XML_PATH is ignored #21

JimMcL opened this issue Jan 19, 2018 · 1 comment

Comments

@JimMcL
Copy link

JimMcL commented Jan 19, 2018

R/windows/load.R contains an .onLoad function which unconditionally sets the UDUNITS2_XML_PATH environment variable, so ignores any user specified value. I don't know why this was done, and I don't know whether it's specific to Windows (as suggested by the directory name), but it makes it difficult to specify a database with custom units.

Workaround:

# Load but don't attach library
loadNamespace("udunits2")
Sys.setenv(UDUNITS2_XML_PATH = "udunits/udunits2.xml")
# Attach library, read database using new value of UDUNITS2_XML_PATH
library(udunits2)
@maier-m
Copy link

maier-m commented Mar 28, 2018

I am having the same issue. The following runs perfectly on macOS but fails on Windows, and having to call library() is not an option for package development.

p0 <- "path_to_modified_udunits2.xml"
Sys.setenv(UDUNITS2_XML_PATH = p0)
udunits2:::.onLoad(dirname(system.file(package = "udunits2")), "udunits2")
Sys.getenv("UDUNITS2_XML_PATH") == p0

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

2 participants