sh: clang++ -mmacosx-version-min=10.13: command not found
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 1.1k
- Forks
- 266
- Avg merge
- 2h 56m
- Merged PRs (30d)
- 1
Description
Summary:
Received a warning when compiling with the latest version of the develop branch on R 4.0.x on MacOS that says "the NEXT version of Stan will not be able to pre-process your Stan program." This seems to be because R CMD config CXX14 returns clang++ -mmacosx-version-min=10.13 instead of just clang++
Description:
The warning says in full:
sh: clang++ -mmacosx-version-min=10.13: command not found
The NEXT version of Stan will not be able to pre-process your Stan program.
Please open an issue at
https://github.com/stan-dev/stanc3/issues
if you can share or at least describe your Stan program. This will help ensure that Stan
continues to work on your Stan programs in the future. Thank you!
This message can be avoided by wrapping your function call inside suppressMessages().
Additional warning messages include:
Warning messages:
1: In system2(CXX, args = ARGS) : error in running command
2: In file.remove(c(unprocessed, processed)) :
cannot remove file '/var/folders/rl/46xg9hmn34g8clr_dwqqn48m0000gp/T//RtmpurL17p/file9a1462472c1c.stan', reason 'No such file or directory'
After looking at the code, this is what I think may be the problem:
The offending line from Warning Message 1 is Line 123 of stanc.R, which calls system2. The first argument of system2 must, according to the docs, be a single command without arguments. However, get_CXX() returns the output of R CMD config CXX14. In the case of R 4.0.0 and greater on MacOS the result is clang++ -mmacosx-version-min=10.13, which does have an argument and causes the system2 call to fail.
Since all of this is in stanc_beta, it falls back to the older compiler and finishes correctly--until the next version, according to the warning.
I updated from R 4.0.0 to 4.0.1 today and the problem occurs with both versions.
Reproducible Steps:
- On MacOS open R >= 4.0.0 in terminal
- Install latest rstan
remotes::install_github("stan-dev/rstan", ref = "develop", subdir = "rstan/rstan", build_opts = "") - Run the example code in rstan's
stanfunction:library(rstan) scode <- " parameters { real y[2]; } model { y[1] ~ normal(0, 1); y[2] ~ double_exponential(0, 2); } " fit1 <- stan(model_code = scode, iter = 10, verbose = TRUE) print(fit1)
Current Output:
Despite showing the warning above, it compiles correctly and the output is otherwise as expected
Expected Output:
The output without the warning
RStan Version:
2.21.1 (f083ce6)
R Version:
R version 4.0.1 (2020-06-06)
Operating System:
MacOS Catalina 10.15.5
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in rstan/rstan/R/stanc.R at the system2 call around line 123, then trace how get_CXX() supplies the compiler command from R CMD config CXX14. Run the reported R 4.0.x macOS reproduction with the example stan call; done means compilation completes without the command-not-found or follow-up warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, r
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100