I installed conda as described in the wiki. conda-shell opens a shell, in which all conda-related commands work as expected (i.e. working with python environments works flawlessly). However, installing an R environment leads to a broken R installation: It seems that several standard-libraries cannot be found by the R interpreter:
(base) conda-shell-chrootenv:moritz@moxps:~$ conda create -n r_env r-essentials r-base
... everything installs fine ...
(base) conda-shell-chrootenv:moritz@moxps:~$ conda activate r_env
(r_env) conda-shell-chrootenv:moritz@moxps:~$ R
R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
Error: package or namespace load failed for ‘utils’:
.onLoad failed in loadNamespace() for 'utils', details:
call: system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE)
error: error in running command
Error: package or namespace load failed for ‘stats’:
.onLoad failed in loadNamespace() for 'utils', details:
call: system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE)
error: error in running command
During startup - Warning messages:
1: package ‘utils’ in options("defaultPackages") was not found
2: package ‘stats’ in options("defaultPackages") was not found
I failed in finding similar errors on the web, so I suspect it’s a nixos-specific error, however I am completely out of ideas on how to find out why R cannot find these packages. utils for example seems to be present in the environment:
Shoot. There are a couple of other environment variables to try, plus the .libPaths() function which shows the full list of search paths (might be helpful for debugging).
Thank you @roni.
libPaths seems to point to the correct location. I was reading a bit about the other environment variables, but didn’t see a light. I’m trying to use the nix-version of R for now. Thank you for the support!!
R depends on which, which might not be present in the conda R environment. Maybe it could be as simple as to add the which-derivation to conda?
Placing ‘which’ into the conda binary folder did however not fix the issue (the R console still complains about not being able to load stats and utils packages)
mach-nix looks great! Thanks for pointing me to it @igel. Unfortunately, I am using a system that requires conda (snakemake) to run the way I want it to.
@GTrunSec although it heavily looks like this is the issue for me, I still get the same error even after setting R_HOME (it was indeed unset before…):
Hi @unode - I am running into the same problems, however with a different Conda setup over julia, concretely pkgs.julia_1.9-bin
The overwrite you mention does not work there… what am I doing wrong?
In nix repl '<nixpkgs/nixos>' I am doing the following
nix-repl> pkgs.julia_19-bin.override {extraPkgs = [ pkgs.which ];}
error: anonymous function at /nix/store/4yxy56fn7phrrkvapvd2cc8kzy958krd-nixos-23.05/nixos/pkgs/development/compilers/julia/1.9-bin.nix:1:1 called with unexpected argument 'extraPkgs'
at /nix/store/4yxy56fn7phrrkvapvd2cc8kzy958krd-nixos-23.05/nixos/lib/customisation.nix:80:16:
79| let
80| result = f origArgs;
| ^
81|
I can confirm what @moritzschaefer said and also that adding which to /usr/bin/which fixes the problem.
The path is hardcoded, simply having which in $PATH is not sufficient.
@schlichtanderswhich was added to the conda environment. In your case you are trying to modify julia’s derivation directly. conda environments in nix are a little special because they use a FHS sandbox that fakes the presence of some binaries in /usr/bin. This doesn’t usually happen with other software unless the software has special requirements.
It’s not clear from your message if the errors in julia are also caused by which missing from /usr/bin nor if julia-bin is hardcoded to look for binaries under /usr/bin/.