Skip to content

Commit

Permalink
update ark call for getting ipykernel path
Browse files Browse the repository at this point in the history
  • Loading branch information
t-kalinowski committed Nov 14, 2024
1 parent 9a6dbea commit 4b752c0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,20 @@ import_positron_ipykernel_inspectors <- function() {
if(!is_positron())
return (NULL)

.ps.positron_ipykernel_path <- get0(".ps.positron_ipykernel_path", globalenv())
if (!is.null(.ps.positron_ipykernel_path)) {
path <- .ps.positron_ipykernel_path()
if (grepl("positron_ipykernel[/\\]?$", path))
path <- dirname(path)
inspectors <- import_from_path("positron_ipykernel.inspectors", path = path)
tryCatch({
# https://github.com/posit-dev/positron/pull/5368
.ps.ui.executeCommand <- get(".ps.ui.executeCommand", globalenv())
ipykernel_path <- .ps.ui.executeCommand("positron.reticulate.getIPykernelPath")
inspectors <- import_from_path("positron_ipykernel.inspectors",
path = dirname(ipykernel_path))
return(inspectors)
}
},
error = function(e) NULL)


# hacky "usually work" fallbacks for finding the positron-python extension,
# until ark+positron are updated and can reliably provide the canonical path
# (i.e., until https://github.com/posit-dev/positron/pull/5368 is in the release build)

# Try inspecting `_` env var. Only works in some contexts.
x <- Sys.getenv("_")
Expand Down

0 comments on commit 4b752c0

Please sign in to comment.