Reinstalled R on mac M1, and RCall no longer works
michaelschwob opened this issue · 2 comments
RCall used to work perfectly for me. Now, after running "using RCall", I get the following error:
julia> using RCall
ERROR: could not load library "/Library/Frameworks/R.framework/Resources/lib/libR.dylib"
dlopen(/Library/Frameworks/R.framework/Resources/lib/libR.dylib, 0x0001): tried: '/Library/Frameworks/R.framework/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/R.framework/Resources/lib/libR.dylib' (no such file), '/Library/Frameworks/R.framework/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib' (no such file), '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
ERROR: InitError: Try adding /Library/Frameworks/R.framework/Resources/lib to the "LD_LIBRARY_PATH" environmental variable and restarting Julia.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] validate_libR(libR::String)
@ RCall ~/.julia/packages/RCall/Wyd74/deps/setup.jl:26
[3] __init__()
@ RCall ~/.julia/packages/RCall/Wyd74/src/setup.jl:174
[4] _include_from_serialized(path::String, depmods::Vector{Any})
@ Base ./loading.jl:768
[5] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
@ Base ./loading.jl:854
[6] _require(pkg::Base.PkgId)
@ Base ./loading.jl:1097
[7] require(uuidkey::Base.PkgId)
@ Base ./loading.jl:1013
[8] require(into::Module, mod::Symbol)
@ Base ./loading.jl:997
during initialization of module RCall
caused by: could not load library "/Library/Frameworks/R.framework/Resources/lib/libR.dylib"
dlopen(/Library/Frameworks/R.framework/Resources/lib/libR.dylib, 0x0001): tried: '/Library/Frameworks/R.framework/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/R.framework/Resources/lib/libR.dylib' (no such file), '/Library/Frameworks/R.framework/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib' (no such file), '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
Stacktrace:
[1] dlopen(s::String, flags::UInt32; throw_error::Bool)
@ Base.Libc.Libdl ./libdl.jl:117
[2] dlopen (repeats 2 times)
@ ./libdl.jl:117 [inlined]
[3] validate_libR(libR::String)
@ RCall ~/.julia/packages/RCall/Wyd74/deps/setup.jl:16
[4] __init__()
@ RCall ~/.julia/packages/RCall/Wyd74/src/setup.jl:174
[5] _include_from_serialized(path::String, depmods::Vector{Any})
@ Base ./loading.jl:768
[6] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
@ Base ./loading.jl:854
[7] _require(pkg::Base.PkgId)
@ Base ./loading.jl:1097
[8] require(uuidkey::Base.PkgId)
@ Base ./loading.jl:1013
[9] require(into::Module, mod::Symbol)
@ Base ./loading.jl:997
I was trying to follow this page. I added RCall, got the R home directory (/Library/Frameworks/R.framework/Resources
from R's R.home()
), set the environmental variable R_HOME
, and attempted to build RCall. In doing so, I get a similar error as above:
julia> Pkg.build("RCall")
Building Conda → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/6e47d11ea2776bc5627421d59cdcc1296c058071/build.log`
Building RCall → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/2c0ffd39860c9a48259a0f57214ced2024ab63bc/build.log`
ERROR: Error building `RCall`:
ERROR: could not load library "/Library/Frameworks/R.framework/Resources/lib/libR.dylib"
dlopen(/Library/Frameworks/R.framework/Resources/lib/libR.dylib, 0x0001): tried: '/Library/Frameworks/R.framework/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/R.framework/Resources/lib/libR.dylib' (no such file), '/Library/Frameworks/R.framework/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib' (no such file), '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
ERROR: LoadError: Try adding /Library/Frameworks/R.framework/Resources/lib to the "LD_LIBRARY_PATH" environmental variable and restarting Julia.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] validate_libR(libR::String)
@ Main ~/.julia/packages/RCall/Wyd74/deps/setup.jl:26
[3] locate_libR(Rhome::SubString{String})
@ Main ~/.julia/packages/RCall/Wyd74/deps/setup.jl:43
[4] top-level scope
@ ~/.julia/packages/RCall/Wyd74/deps/build.jl:58
[5] include(fname::String)
@ Base.MainInclude ./client.jl:451
[6] top-level scope
@ none:5
in expression starting at /Users/schwob/.julia/packages/RCall/Wyd74/deps/build.jl:11
caused by: could not load library "/Library/Frameworks/R.framework/Resources/lib/libR.dylib"
dlopen(/Library/Frameworks/R.framework/Resources/lib/libR.dylib, 0x0001): tried: '/Library/Frameworks/R.framework/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/R.framework/Resources/lib/libR.dylib' (no such file), '/Library/Frameworks/R.framework/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib' (no such file), '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
Stacktrace:
[1] dlopen(s::String, flags::UInt32; throw_error::Bool)
@ Base.Libc.Libdl ./libdl.jl:117
[2] dlopen (repeats 2 times)
@ ./libdl.jl:117 [inlined]
[3] validate_libR(libR::String)
@ Main ~/.julia/packages/RCall/Wyd74/deps/setup.jl:16
[4] locate_libR(Rhome::SubString{String})
@ Main ~/.julia/packages/RCall/Wyd74/deps/setup.jl:43
[5] top-level scope
@ ~/.julia/packages/RCall/Wyd74/deps/build.jl:58
[6] include(fname::String)
@ Base.MainInclude ./client.jl:451
[7] top-level scope
@ none:5
Stacktrace:
[1] pkgerror(msg::String)
@ Pkg.Types /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/Types.jl:68
[2] (::Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec})()
@ Pkg.Operations /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:962
[3] withenv(::Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, ::Pair{String, String}, ::Vararg{Pair{String}})
@ Base ./env.jl:172
[4] (::Pkg.Operations.var"#99#103"{String, Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec})()
@ Pkg.Operations /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1506
[5] with_temp_env(fn::Pkg.Operations.var"#99#103"{String, Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec}, temp_env::String)
@ Pkg.Operations /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1390
[6] (::Pkg.Operations.var"#98#102"{Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String})(tmp::String)
@ Pkg.Operations /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1469
[7] mktempdir(fn::Pkg.Operations.var"#98#102"{Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String}, parent::String; prefix::String)
@ Base.Filesystem ./file.jl:750
[8] mktempdir(fn::Function, parent::String) (repeats 2 times)
@ Base.Filesystem ./file.jl:748
[9] sandbox(fn::Function, ctx::Pkg.Types.Context, target::Pkg.Types.PackageSpec, target_path::String, sandbox_path::String, sandbox_project_override::Pkg.Types.Project; force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool)
@ Pkg.Operations /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1435
[10] sandbox(fn::Function, ctx::Pkg.Types.Context, target::Pkg.Types.PackageSpec, target_path::String, sandbox_path::String, sandbox_project_override::Pkg.Types.Project)
@ Pkg.Operations /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1432
[11] build_versions(ctx::Pkg.Types.Context, uuids::Set{Base.UUID}; verbose::Bool)
@ Pkg.Operations /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:943
[12] build(ctx::Pkg.Types.Context, uuids::Set{Base.UUID}, verbose::Bool)
@ Pkg.Operations /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:822
[13] build(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; verbose::Bool, kwargs::Base.Pairs{Symbol, Base.TTY, Tuple{Symbol}, NamedTuple{(:io,), Tuple{Base.TTY}}})
@ Pkg.API /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/API.jl:992
[14] build(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Pkg.API /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/API.jl:149
[15] build(pkgs::Vector{Pkg.Types.PackageSpec})
@ Pkg.API /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/API.jl:144
[16] #build#99
@ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/API.jl:142 [inlined]
[17] build
@ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/API.jl:142 [inlined]
[18] #build#98
@ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/API.jl:141 [inlined]
[19] build(pkg::String)
@ Pkg.API /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/API.jl:141
[20] top-level scope
@ REPL[3]:1
How can I resolve this issue? Why did this happen after reinstalling R?
I get a similar error. I set R_HOME
properly, Pkg.build("RCall")
successfully, but any R call fails with this error pointing to nonexistent lib4.dylib
:
julia> rcall("print('sadfasd')")
ERROR: could not load library "/opt/homebrew/Cellar/r/4.2.1_2/lib/R/lib/libR.dylib"
dlopen(/opt/homebrew/Cellar/r/4.2.1_2/lib/R/lib/libR.dylib, 0x0001): tried: '/opt/homebrew/Cellar/r/4.2.1_2/lib/R/lib/libR.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/r/4.2.1_2/lib/R/lib/libR.dylib' (no such file), '/opt/homebrew/Cellar/r/4.2.1_2/lib/R/lib/libR.dylib' (no such file)
Stacktrace:
[1] allocArray
@ ~/.julia/packages/RCall/6kphM/src/methods.jl:399 [inlined]
[2] rlang_p(::String; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ RCall ~/.julia/packages/RCall/6kphM/src/language.jl:4
[3] rlang_p
@ ~/.julia/packages/RCall/6kphM/src/language.jl:2 [inlined]
[4] #rcall_p#28
@ ~/.julia/packages/RCall/6kphM/src/language.jl:30 [inlined]
[5] rcall_p
@ ~/.julia/packages/RCall/6kphM/src/language.jl:30 [inlined]
[6] rcall(::String; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ RCall ~/.julia/packages/RCall/6kphM/src/language.jl:37
[7] rcall(::String)
@ RCall ~/.julia/packages/RCall/6kphM/src/language.jl:37
[8] top-level scope
@ REPL[21]:1
To the best of my knowledge, I have no R installed by homebrew nor there isn't any symlink to that location.
EDIT: I've just installed new julia (was 1.8.0) and the problem went away.
I suspect the original problem is related to running some native M1 binaries and some x86-64 binaries via Rosetta. I'm closing this as stale, but if it's still present on recent M1 versions of both R and Julia (1.8+), then please re-open.