Skip to content

Commit 96445db

Browse files
authored
Merge pull request #49 from e-kotov/dev
fix java_env_set_session
2 parents d7bb4b1 + fd6148f commit 96445db

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@
2424
^vignettes/.quarto$
2525
^revdep$
2626
^man/figures/card.png$
27+
^tools$

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: rJavaEnv
22
Title: 'Java' Environments for R Projects
3-
Version: 0.2.1
3+
Version: 0.2.1.9000
44
Authors@R: c(
55
person("Egor", "Kotov", , "[email protected]", role = c("aut", "cre", "cph"),
66
comment = c(ORCID = "0000-0001-6690-5345")),

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# rJavaEnv (development version)
2+
13
# rJavaEnv 0.2.1 (2024-09-03)
24

35
* Documentation and description clean-up

R/java_env.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,14 @@ java_env_set <- function(
8484
java_env_set_session <- function(java_home) {
8585

8686
# check if rJava is installed and alread initialized
87-
if (requireNamespace("rJava", quietly = TRUE)) {
88-
if( getFromNamespace(".jniInitialized", "rJava") == TRUE ) {
89-
cli::cli_inform(c("!" = "You have already initialised `rJava` directly or via your Java-dependent R package in the current session. `Java` version can only be set once per session for packages that rely on `rJava`. Unless you restart the R session or run your code in a new R subprocess using `targets` or `callr`, the new `JAVA_HOME` and `PATH` will not take effect."))
87+
if (any(installed.packages()[, 1] == "rJava")) {
88+
if( "rJava" %in% loadedNamespaces() == TRUE ) {
89+
cli::cli_inform(c("!" = "You have `rJava` R package loaded in the current session. If you have already initialised it directly with ``rJava::.jinit()` or via your Java-dependent R package in the current session, you may not be able to switch to a different `Java` version unless you restart R. `Java` version can only be set once per session for packages that rely on `rJava`. Unless you restart the R session or run your code in a new R subprocess using `targets` or `callr`, the new `JAVA_HOME` and `PATH` will not take effect."))
9090
}
9191
}
9292

9393
Sys.setenv(JAVA_HOME = java_home)
94+
9495
old_path <- Sys.getenv("PATH")
9596
new_path <- file.path(java_home, "bin")
9697
Sys.setenv(PATH = paste(new_path, old_path, sep = .Platform$path.sep))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# before release
2+
# usethis::use_version("patch")
3+
cffr::cff_write()
4+
codemetar::write_codemeta(write_minimeta = T)
5+
usethis::use_tidy_description()
6+
# urlchecker::url_check()
7+
# devtools::check(remote = TRUE, manual = TRUE)
8+
# devtools::check_win_devel()
9+
# revdepcheck::revdep_check(num_workers = 4)
10+
11+
# devtools::submit_cran()
12+
13+
# usethis::use_github_release()
14+
# usethis::use_dev_version(push = TRUE)

0 commit comments

Comments
 (0)