Closed mnacamura closed 6 years ago
This test passed:
#! /usr/bin/env nix-shell --pure
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "r-darwin-libcxx-test";
buildInputs = [ (rWrapper.override { packages = [rPackages.rstan]; }) ];
shellHook = ''
cat > example.stan << CODE
data {
int<lower=0> N;
real X[N];
}
parameters {
real Mu;
real<lower=0> Sigma;
}
model {
Mu ~ cauchy(0, 5);
Sigma ~ cauchy(0, 5);
X ~ normal(Mu, Sigma);
}
CODE
Rscript -e 'library(rstan); stan_model("example.stan")'
exit 0
'';
}
Inside nix-shell, no problem. Outside nix-shell, clang called by R cannot find lbcxx headers.
I guess the point is that inside nix-shell, NIX_LDFLAGS
and NIX_CFLAGS_COMPILE
include paths to libcxx but outside nix-shell, these environmental variables are missing.
Ah! That explains the issue, linux would probably have the same problem but with stdc++.
It seems a more general issue (#6390, https://nixos.org/nixpkgs/manual/#builds-on-darwin-fail-with-math.h-not-found).
I confirmed that it is okay on Linux. Close this issue for the moment.
Issue description
On Darwin, clang executed inside R cannot find a C++ header 'cstdlib'. This problem can be solved by installing
libcxx
and puttingin
~/.R/Makevars
. However, it would be better if R does find 'cstdlib' without this hack.Steps to reproduce
Install R with rstan, which uses 'StanHeaders' including cstdlib:
Compile a Stan model, for example, this
example.stan
:parameters { real Mu; real Sigma;
}
model { Mu ~ cauchy(0, 5); Sigma ~ cauchy(0, 5); X ~ normal(Mu, Sigma); }
Technical details
"x86_64-darwin"
Darwin 17.5.0, macOS 10.13.4
no
no
nix-env (Nix) 1.12pre5849_74f75c85
"darwin, nixpkgs-18.03pre126020.931a0b8be80"
/Users/mnacamura/Repos/nixpkgs