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

'R_user_dir' is not an exported object from 'namespace:tools' #458

Closed
amirmazmi opened this issue Oct 9, 2024 · 3 comments
Closed

'R_user_dir' is not an exported object from 'namespace:tools' #458

amirmazmi opened this issue Oct 9, 2024 · 3 comments
Labels
help wanted ❤️ we'd love your help!

Comments

@amirmazmi
Copy link

Getting the below error trying to use duckdb.

Installation step:
install.packages("duckdb")
which then compiles duckdb


try to run as per below

> con <- duckdb::dbConnect(duckdb())
Error: 'R_user_dir' is not an exported object from 'namespace:tools'

For this version of R (3.6.3 ), R_user_dir is in backports. Not sure what namespace::tools is.


Tried running

> duckdb()
Error: 'R_user_dir' is not an exported object from 'namespace:tools'

which is most likely the source calling R_user_dir()



If no workaround exists, any chance a previous version of duckdb would work with R 3.6.3? Current work centred around this version for now.



sessionInfo()

R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
[1] LC_CTYPE=en_SG.UTF-8 LC_NUMERIC=C LC_TIME=en_SG.UTF-8 LC_COLLATE=en_SG.UTF-8
[5] LC_MONETARY=en_SG.UTF-8 LC_MESSAGES=en_SG.UTF-8 LC_PAPER=en_SG.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_SG.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] duckdb_1.1.0 DBI_1.1.1 pacman_0.5.1

loaded via a namespace (and not attached):
[1] compiler_3.6.3 tools_3.6.3

@krlmlr
Copy link
Collaborator

krlmlr commented Oct 28, 2024

Thanks. It seems that duckdb requires R 4.0.0 in this case. Happy to review a PR that works around, though.

The {tools} package is one of R's base packages.

tools::R_user_dir
#> function (package, which = c("data", "config", "cache")) 
#> {
#>     stopifnot(is.character(package), length(package) == 1L)
#>     which <- match.arg(which)
#>     home <- normalizePath("~")
#>     path <- switch(which, data = {
#>         if (nzchar(p <- Sys.getenv("R_USER_DATA_DIR"))) p else if (nzchar(p <- Sys.getenv("XDG_DATA_HOME"))) p else if (.Platform$OS.type == 
#>             "windows") file.path(Sys.getenv("APPDATA"), "R", 
#>             "data") else if (Sys.info()["sysname"] == "Darwin") file.path(home, 
#>             "Library", "Application Support", "org.R-project.R") else file.path(home, 
#>             ".local", "share")
#>     }, config = {
#>         if (nzchar(p <- Sys.getenv("R_USER_CONFIG_DIR"))) p else if (nzchar(p <- Sys.getenv("XDG_CONFIG_HOME"))) p else if (.Platform$OS.type == 
#>             "windows") file.path(Sys.getenv("APPDATA"), "R", 
#>             "config") else if (Sys.info()["sysname"] == "Darwin") file.path(home, 
#>             "Library", "Preferences", "org.R-project.R") else file.path(home, 
#>             ".config")
#>     }, cache = {
#>         if (nzchar(p <- Sys.getenv("R_USER_CACHE_DIR"))) p else if (nzchar(p <- Sys.getenv("XDG_CACHE_HOME"))) p else if (.Platform$OS.type == 
#>             "windows") file.path(Sys.getenv("LOCALAPPDATA"), 
#>             "R", "cache") else if (Sys.info()["sysname"] == "Darwin") file.path(home, 
#>             "Library", "Caches", "org.R-project.R") else file.path(home, 
#>             ".cache")
#>     })
#>     file.path(path, "R", package)
#> }
#> <bytecode: 0x11047dda8>
#> <environment: namespace:tools>

Created on 2024-10-28 with reprex v2.1.1

@krlmlr krlmlr added the help wanted ❤️ we'd love your help! label Oct 28, 2024
@krlmlr
Copy link
Collaborator

krlmlr commented Oct 28, 2024

Looks like you can work around in R < 4.0.0 with something like:

dbConnect(
  duckdb(config(extension_directory = ..., secret_directory = ...))
)

With that, the R_user_dir() function isn't called. Not bumping the required R version for now, but certainly could use better behavior or a true fix.

@amirmazmi
Copy link
Author

amirmazmi commented Nov 12, 2024

Thanks for this!

Working example

con <-duckdb::dbConnect( 
       duckdb( config = list( extension_directory = getwd(), secret_directory = getwd()))
)

Can be closed as a workaround has been found.

@krlmlr krlmlr closed this as completed Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted ❤️ we'd love your help!
Projects
None yet
Development

No branches or pull requests

2 participants