Open kaneplusplus opened 8 months ago
I cannot reproduce this error on the master branch. (f98a3ccfa6faa5da98aa361835f005fc9a148f5d) Can you tell me the revision of nix-channel?
Certainly.
> nix-channel --version
nix-channel (Nix) 2.20.4
If it's helpful, I'm happy to completely uninstall, retry, and report back.
OK, I figured it out.
If I start a nix-shell and check .libPaths()
(where R looks for packages). I get the following:
> nix-shell -p R rPackages.ggplot2
[nix-shell:~/projects/telperian/build-and-deploy/build-packages/MCRC/inst/sim-real]$ R
...
> head(.libPaths())
[1] "/Users/mike/Library/R/arm64/4.3/library"
[2] "/nix/store/1pabv9bhqx6fsvc4lzs1darqrs1gnjvc-r-ggplot2-3.4.4/library"
[3] "/nix/store/3mcgh9kp5jfwi4ikq7c6g63imilajcfq-r-cli-3.6.2/library"
[4] "/nix/store/1722gizcnb92k3akvnkpn8mj9xd63asl-r-glue-1.6.2/library"
[5] "/nix/store/9axazs50jwrqcfdhpya0v96kcv53vkac-r-gtable-0.3.4/library"
For some reason the first place R looks for R packages on my machine is where my mac arm64 packages are. R tries to load the package and crashes.
A fix is to get rid of the first entry in .libPaths()
with:
> .libPaths(.libPaths()[-1])
> head(.libPaths())
[1] "/nix/store/1pabv9bhqx6fsvc4lzs1darqrs1gnjvc-r-ggplot2-3.4.4/library"
[2] "/nix/store/3mcgh9kp5jfwi4ikq7c6g63imilajcfq-r-cli-3.6.2/library"
[3] "/nix/store/1722gizcnb92k3akvnkpn8mj9xd63asl-r-glue-1.6.2/library"
...
Now I can load packages.
Do you have it set in .Rprofile
?
I do not. I'm not sure why it was getting the first path from.
@jbedo Can we change to not inheriting R_LIBS_USER
, which is the default on both macOS and linux for nix R builds, if it exists? It causes a lot of pain and runtime impurity by default, which should really be avoided. We use R_LIBS_SITE
in nix. Shall i make a separate issue for it? @kaneplusplus we have rix::rix_init()
that writes a custom .Rprofile
that removes R_LIBS_USER
from .libPaths() by default. It works, but i really would like that R packaged in nixpkgs has a better default.
@jbedo Can we change to not inheriting
R_LIBS_USER
, which is the default on both macOS and linux for nix R builds, if it exists? It causes a lot of pain and runtime impurity by default, which should really be avoided. We useR_LIBS_SITE
in nix. Shall i make a separate issue for it? @kaneplusplus we haverix::rix_init()
that writes a custom.Rprofile
that removesR_LIBS_USER
from .libPaths() by default. It works, but i really would like that R packaged in nixpkgs has a better default.
I don't think that's a good idea, there are users that rely on that functionality. I also generally prefer to keep behaviour as close to upstream as possible. We already have ways to increase purity (e.g., the --pure
) flag.
@jbedo Can we change to not inheriting
R_LIBS_USER
, which is the default on both macOS and linux for nix R builds, if it exists? It causes a lot of pain and runtime impurity by default, which should really be avoided. We useR_LIBS_SITE
in nix. Shall i make a separate issue for it? @kaneplusplus we haverix::rix_init()
that writes a custom.Rprofile
that removesR_LIBS_USER
from .libPaths() by default. It works, but i really would like that R packaged in nixpkgs has a better default.I don't think that's a good idea, there are users that rely on that functionality. I also generally prefer to keep behaviour as close to upstream as possible. We already have ways to increase purity (e.g., the
--pure
) flag.
nix-shell --pure
does not change the system-polluted .libPaths()
, since its a runtime purity problem. I still think its a bad idea to have this default.
.libPaths()
to include R_LIBS_USERS
. What use cases do see that cannot be tackled otherwise?The tradeoff is between two groups of users, those who manage R dependencies with Nix exclusively and those that do not. The change you're suggesting diverges from upstream behaviour and favours the former group at the expense of the latter. Either way does not prevent users from achieving their goals, but I feel not changing upstream defaults is least surprising and also has lower maintenance cost, particularly with documentation.
This discussion is worthwhile however offtopic for this issue, let's continue in a new one.
Describe the bug
I'm getting a segfault when trying to load libraries in R in the nix-shell on a Mac M1.
Steps To Reproduce
Steps to reproduce the behavior:
nix-shell -p R rPackages.dplyr
Rscript -e "library(dplyr)"
.Expected behavior
I expected the library to load and then R to exit back to the nix-shell. Please note that this does not appear to be
dplyr
specific. I'm able to reproduce this with every other package I tried (ggplot2
,survival
, etc.).Screenshots
Additional context
Add any other context about the problem here.
Notify maintainers
@adisbladis
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.