You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
setwd("~/projects/Github/")
packageVersion("import")
#> [1] ‘1.3.0.9004’if (dir.exists("pkgs")) unlink("pkgs", recursive=TRUE)
dir.create("pkgs")
dir.create("pkgs/0.1.0")
dir.create("pkgs/0.2.0")
# Download Files from https://github.com/DavZim/testPkgif (!file.exists("testPkg_0.1.0.tar.gz"))
download.file("https://github.com/DavZim/testPkg/releases/download/v0.1.0/testPkg_0.1.0.tar.gz", "testPkg_0.1.0.tar.gz")
if (!file.exists("testPkg_0.2.0.tar.gz"))
download.file("https://github.com/DavZim/testPkg/releases/download/v0.2.0/testPkg_0.2.0.tar.gz", "testPkg_0.2.0.tar.gz")
install.packages("testPkg_0.1.0.tar.gz", "pkgs/0.1.0", NULL)
install.packages("testPkg_0.2.0.tar.gz", "pkgs/0.2.0", NULL)
import::from("testPkg", .library="pkgs/0.1.0", .into="A", foo)
import::from("testPkg", .library="pkgs/0.2.0", .into="B", foo)
search()
#> [1] ".GlobalEnv" "B" "A" #> [4] "package:stats" "package:graphics" "package:grDevices"#> [7] "package:utils" "package:datasets" "package:methods" #> [10] "Autoloads" "tools:callr" "package:base"
ls("A")
#> [1] "?" "foo"
ls("B")
#> [1] "?" "foo"
get("foo", "A")
#> function () #> {#> "Hello World from Version 0.1.0"#> }#> <bytecode: 0x000000002159b1b0>#> <environment: namespace:testPkg>
get("foo", "B")
#> function () #> {#> "Hello World from Version 0.1.0"#> }#> <bytecode: 0x000000002159b1b0>#> <environment: namespace:testPkg># NO GOOD should read 0.2.0 for the second one
Second attempt with libPaths changes
lb<- .libPaths()
.libPaths("pkgs/0.1.0")
import::from("testPkg", .library="pkgs/0.1.0", .into="A", foo)
.libPaths("pkgs/0.2.0")
import::from("testPkg", .library="pkgs/0.2.0", .into="B", foo)
.libPaths(lb)
get("foo", "A")
#> function () #> {#> "Hello World from Version 0.1.0"#> }#> <bytecode: 0x000000002159b1b0>#> <environment: namespace:testPkg>
get("foo", "B")
#> function () #> {#> "Hello World from Version 0.1.0"#> }#> <bytecode: 0x000000002159b1b0>#> <environment: namespace:testPkg># NO GOOD should read 0.2.0 for the second one