radian: Bus Error on Radian Launch
I think the error occurs on L22 in init.R of vscode-r:
Show Error
> radian
*** caught bus error ***
address 0x100c466d0, cause 'invalid alignment'
Traceback:
1: dyn.load(file, DLLpath = DLLpath, ...)
2: library.dynam(lib, package, package.lib)
3: loadNamespace(package, ...)
4: doTryCatch(return(expr), name, parentenv, handler)
5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
6: tryCatchList(expr, classes, parentenv, handlers)
7: tryCatch(loadNamespace(package, ...), error = function(e) e)
8: FUN(X[[i]], ...)
9: vapply(required_packages, requireNamespace, logical(1L), quietly = TRUE)
10: init_first()
11: eval(ei, envir)
12: eval(ei, envir)
13: withVisible(eval(ei, envir))
14: source("/Users/eyayaw/.vscode/extensions/reditorsupport.r-2.8.2/R/session/init.R", chdir = TRUE, local = TRUE)
15: eval(quote(source("/Users/eyayaw/.vscode/extensions/reditorsupport.r-2.8.2/R/session/init.R", chdir = TRUE, local = TRUE)), new.env())
16: eval(quote(source("/Users/eyayaw/.vscode/extensions/reditorsupport.r-2.8.2/R/session/init.R", chdir = TRUE, local = TRUE)), new.env())
17: eval(expr, p)
18: eval(expr, p)
19: eval.parent(substitute(eval(quote(expr), envir)))
20: local(source("/Users/eyayaw/.vscode/extensions/reditorsupport.r-2.8.2/R/session/init.R", chdir = TRUE, local = TRUE))
21: eval(ei, envir)
22: eval(ei, envir)
23: withVisible(eval(ei, envir))
24: source(file.path(Sys.getenv(if (.Platform$OS.type == "windows") "USERPROFILE" else "HOME"), ".vscode-R", "init.R"))
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 1
R is aborting now ...
zsh: bus error radian
Radian version
> radian --version
radian version: 0.6.7
r executable: /Library/Frameworks/R.framework/Resources/bin/R
r version: 4.3.1
python executable: /opt/homebrew/opt/python@3.11/bin/python3.11
python version: 3.11.6
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 4
- Comments: 33 (6 by maintainers)
Setting
R_HOMEalso did not do the trick for me. And using Homebrew R isn’t really a solution because (last I checked) it prevents the use of CRAN binary packages.If it helps give any clues: reinstalling problematic packages from source makes the issue goes away (e.g., using renv,
renv::install("dplyr", type = "source")— but there were other packages, likehttpuv). But this is too time-consuming across multiple projects to be a real solution, and identifying the culprit packages doesn’t seem entirely trivial, esp with many projects that are using renv.Thanks for the reproducible example. I am able to reproduce the error on my mac. by
Having a look at the
rlang.soCompare to CRAN’s version
It seems that the one from RSPM is missing the linking to
libR.dylib.The library can be forced to be inserted on macOS using
and on unix
Note that it is only a workaround. Ideally, the packages from RSPM should have linked to libR.so/libR.dylib.
What if I want to use radian on MacOS with pyenv and rig, which enables using multiple versions of Python and R? I use pyenv to compile and install Python and rig to maintain multiple versions of R.
I need to support multiple versions of Python and R for my projects and it would be great to find a way to be able to leverage radian in these situations.
Unfortunately, that does not work on my m2. I tried with the homebrew python and r (
brew install --cask r) and the official arm64 r.I think this is a
radianissue - I’m experiencing the caught bus error by using radian in the terminal with no VS Code involved. The error happens when I try to load a package withlibrary.I’m using R 4.3 installed by rig.
I receive no error if I run without radian:
The Bus Error was actually happening in regular
radiansessions withoutrenv. Finally tracked it down.package_info()told me that one package, namely Matrix, was installed from RSPM instead of CRAN. When and how that happened is beyond me.Every package that had Matrix as a dependency caused the Bus Error. Reinstalling Matrix via
install.packages("Matrix")with no special settings completely fixed the problem.I just tested @randy3k’s statement about Homebrew R and Python being the same. I was having this issue when I had the Homebrew cask, but when I installed from the Homebrew formula, the error seems to have disappeared. I recommend others try this out. If your R executable (in
$(brew --prefix)/bin) points to/Library/Frameworks/R.framework..., you have the cask installed. Trybrew uninstall --cask r && brew install r.I was running into the issue when radian would look for the exported members for autocompletion, specifically with cmdstanr. I thought that since cmdstanr has an external dependency it was the issue, but then rmarkdown had a problem. I wonder if there’s some relationship to external libraries that could be hosing the dylib lookup?
This has the assumption that your Python is managed by Homebrew as well!