Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R HOME Environment variable is not read or used in Linux (and maybe macOS) #152

Open
nmunozgarcia opened this issue May 10, 2022 · 1 comment

Comments

@nmunozgarcia
Copy link

nmunozgarcia commented May 10, 2022

In my tests I use Xubuntu 22.04, .Net 6.0.4 (SDK 6.0.202) and two R versions (the one which comes with Ubuntu Jammy Jellyfish repositories (R-4.1.2) and a compiled by my parthner R version (R-4.2.0, the last version right now). In both R versions the results are the same.

First I had a DllNotFoundException:

System.DllNotFoundException: Unable to load shared library 'libdl' or one of its dependencies. 
In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl: cannot open shared object file: No such file or directory

Which I solved installing the libc6-dev package and generating a symbolic link from libdl.so to libdl.so.2 (veldrid/veldrid#143)

sudo apt update
sudo apt install libc6-dev
sudo ln -s /lib/x86_64-linux-gnu/libdl.so.2 /lib/libdl.so

But now, when I execute the test, I get:
Fatal error: R home directory is not defined
on the GetInstance() Method (REngine engine = REngine.GetInstance();)

This can be fixed if, for example, in the terminal where the executable program will run, set a global variable R_HOME executing before:

R_HOME="/usr/lib/R"
export R_HOME

(As @gurza said: #122)

But this can not be the final solution because the environment variables are not working in the .Net program (and they are there for something).

The code I used for my test is the hello world example in the RdotNet project page https://rdotnet.github.io/rdotnet/tut_basic_types/

static void Main(string[] args)
{
    REngine.SetEnvironmentVariables(); // <-- May be omitted; the next line would call it.
    
    // I added this code to test if the R_HOME variable is set
    var environmentVariables = Environment.GetEnvironmentVariables();
    if (environmentVariables.Contains("R_HOME")){   // true, the variable is set
        Console.WriteLine($"R_HOME: {environmentVariables["R_HOME"]}");    // output: **"R_HOME: /usr/local/lib/R"**
    }


    REngine engine = REngine.GetInstance(); // **Fatal error: R home directory is not defined**
    // The code stops here

    ...
}

Maybe related to the #151
If the package stats is not found, the cause may be related to the fact that environment variables are not working.

@nmunozgarcia
Copy link
Author

nmunozgarcia commented May 12, 2022

I see, in the Getting started zone, a content related to Updating environment variables on Linux and MacOS.

But, at least, in my test environment (Xubuntu) the routes don't exists.
I tried with /usr/local/lib as route, but this didn't work (as I expected).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant