Skip to content

Commit 3f55f43

Browse files
authored
Merge pull request #264 from JuliaInterop/fix-macos-arm-compatibility
Fix macOS ARM compatibility issues
2 parents 4119868 + 23533c6 commit 3f55f43

File tree

9 files changed

+98
-14
lines changed

9 files changed

+98
-14
lines changed

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ Imports: utils,
2727
Rcpp (>= 0.12.7),
2828
knitr (>= 1.28),
2929
rjson
30-
RoxygenNote: 7.1.2
30+
RoxygenNote: 7.2.3
3131
LinkingTo: Rcpp
3232
NeedsCompilation: yes
3333
ByteCompile: yes
3434
SystemRequirements: Julia >= 1.0.0, RCall.jl
3535
Suggests: testthat,
3636
rmarkdown,
3737
rappdirs,
38-
sass
38+
sass,
39+
curl
3940
VignetteBuilder: knitr

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ export(julia_help)
6969
export(julia_install_package)
7070
export(julia_install_package_if_needed)
7171
export(julia_installed_package)
72+
export(julia_latest_version)
7273
export(julia_library)
74+
export(julia_lts_version)
7375
export(julia_markdown_setup)
7476
export(julia_notebook_setup)
7577
export(julia_pkg_hook)

R/installJulia.R

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ julia_default_install_dir <- function(){
1111
return(dir)
1212
}
1313

14+
#' Get the latest stable Julia version.
15+
#'
16+
#' @return A numeric_version object representing the latest stable Julia version.
17+
#' @export
1418
julia_latest_version <- function(){
1519
url <- "https://julialang-s3.julialang.org/bin/versions.json"
1620
file <- tempfile()
@@ -20,6 +24,26 @@ julia_latest_version <- function(){
2024
max(numeric_version(names(Filter(function(v) v$stable, versions))))
2125
}
2226

27+
#' Get the latest Long Term Support (LTS) Julia version.
28+
#'
29+
#' @return A numeric_version object representing the latest LTS Julia version.
30+
#' @export
31+
julia_lts_version <- function(){
32+
url <- "https://julialang-s3.julialang.org/bin/versions.json"
33+
file <- tempfile()
34+
utils::download.file(url, file)
35+
versions <- rjson::fromJSON(file=file)
36+
37+
# Find the latest LTS version (currently 1.10.x series)
38+
lts_versions <- names(Filter(function(v) v$stable && isTRUE(v$lts), versions))
39+
if (length(lts_versions) > 0) {
40+
max(numeric_version(lts_versions))
41+
} else {
42+
# Fallback to latest stable if no LTS is marked
43+
julia_latest_version()
44+
}
45+
}
46+
2347

2448
julia_url <- function(version){
2549
sysmachine <- Sys.info()["machine"]
@@ -73,8 +97,9 @@ julia_save_install_dir <- function(dir){
7397
#' Install Julia.
7498
#'
7599
#' @param version The version of Julia to install (e.g. \code{"1.6.3"}).
76-
#' Defaults to \code{"latest"}, which will install the most
77-
#' recent stable release.
100+
#' Defaults to \code{"lts"}, which will install the current
101+
#' Long Term Support release. Can also be \code{"latest"} for
102+
#' the most recent stable release.
78103
#' @param prefix the directory where Julia will be installed.
79104
#' If not set, a default location will be determined by \code{rappdirs}
80105
#' if it is installed, otherwise an error will be raised.
@@ -88,6 +113,8 @@ install_julia <- function(version = "latest",
88113

89114
if (version == "latest") {
90115
version <- julia_latest_version()
116+
} else if (version == "lts") {
117+
version <- julia_lts_version()
91118
}
92119
url <- julia_url(version)
93120

R/zzz.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
#' If a new version of R is used, then this parameter needs to be set to TRUE.
2525
#' @param sysimage_path path to the precompiled custom sys image.
2626
#' Path can be either an absolute path or relative to the current directory.
27-
#' @param version the version of Julia to install. Defaults to "latest", which is the latest
28-
#' released version of Julia. You can use "1.10" for example for Julia v1.10.
27+
#' @param version the version of Julia to install. Defaults to "latest", which is the current
28+
#' latest version of Julia. You can also use "lts" for the most recent
29+
#' long term stable release, or specify a version like "1.10".
2930
#' @return The julia interface, which is an environment with the necessary methods
3031
#' like command, source and things like that to communicate with julia.
3132
#'

inst/julia/install_dependency.jl

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,37 @@ function installed(name)
3232
end
3333

3434
if installed("Suppressor") == nothing
35-
Pkg.add("Suppressor")
35+
# Use try-catch to handle potential package conflicts on ARM64
36+
try
37+
Pkg.add("Suppressor")
38+
catch e
39+
@warn "Failed to install Suppressor directly, trying to resolve in isolated environment" exception=e
40+
# Create a temporary isolated environment to avoid conflicts
41+
temp_env = mktempdir()
42+
Pkg.activate(temp_env)
43+
Pkg.add("Suppressor")
44+
Pkg.activate() # Return to default environment
45+
# Now try again in the main environment
46+
Pkg.add("Suppressor")
47+
end
3648
end;
3749

3850
using Suppressor
3951

4052
if installed("RCall") == nothing
41-
Pkg.add("RCall")
53+
# Use try-catch to handle potential package conflicts on ARM64
54+
try
55+
Pkg.add("RCall")
56+
catch e
57+
@warn "Failed to install RCall directly, trying to resolve in isolated environment" exception=e
58+
# For RCall, we need to be more careful as it needs to be in the main environment
59+
# Try to update registry first which often fixes ARM64 issues
60+
try
61+
Pkg.Registry.update()
62+
catch
63+
@warn "Could not update registry"
64+
end
65+
# Try again after registry update
66+
Pkg.add("RCall")
67+
end
4268
end;

man/install_julia.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/julia_latest_version.Rd

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/julia_lts_version.Rd

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/julia_setup.Rd

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)