You are not logged in.

#1 2018-01-24 20:20:45

woodape
Member
Registered: 2015-03-25
Posts: 159

[SOLVED] R doesn't detect environment variables with ZSH

I've been giving zsh a try as my default shell for a couple of days now, and have run into zero issues until I needed to install a new package in R. I install all my R packages into a local directory so I don't need to drop into root every time I want a new package.

I have in my ".zshenv" file:

R_LIBS="$HOME/.local/share/R/libs"

When I do 'echo "$R_LIBS"' in my terminal, I get "/home/<myuser>/.local/share/R/libs" echoed back. But when I launch R and do 'Sys.getenv("R_LIBS")' from the terminal with the zsh shell, I get an empty string. In fact none of the variables set in my ".zshenv" file are detected in R. The R process doesn't detect my local library, which is an issue because that's where all my R packages are.

If I drop into bash, launch R, and run the same commands, the environment variables are listed like I would expect them to be. Any idea why environment variables would show up in bash but not in zsh?

Last edited by woodape (2018-01-24 20:37:36)

Offline

#2 2018-01-24 20:24:01

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: [SOLVED] R doesn't detect environment variables with ZSH

This has nothing to do with zsh (or R for that matter): you need to export the variables you want inherited by child processes.

Last edited by Trilby (2018-01-24 20:24:16)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-01-24 20:37:21

woodape
Member
Registered: 2015-03-25
Posts: 159

Re: [SOLVED] R doesn't detect environment variables with ZSH

I'm an idiot. I misread the one of the wiki pages. I thought that zsh's environment file exported all the variables defined in it without the "export". Thanks Trilby.

Offline

Board footer

Powered by FluxBB