Forum Discussion

FICO's avatar
FICO
Community Manager
2 years ago

How do you get an R script to locate the Xpress license?

I just installed Xpress optimizer (on Linux MInt) and tried out the first_lp_problem.R example. The call to xprs_loadproblemdata() failed with the message "The license file was not found in '.'." Note that the XPAUTH_PATH environment variable is correctly set. Changing the working directory in the R session to the Xpress bin directory fixed the problem, but it is not practical to require an R session be running in that directory in order to access Xpress.

What is the correct way to get the xpress R library to find the license file?

Thanks.

3 Replies

  • FICO's avatar
    FICO
    Community Manager

    Answering myself (seldom a good sign): This is actually an RStudio problem, not an Xpress issue. If I run R in a terminal and source the .R file, it runs fine. The error only occurs when I run the example in the RStudio IDE (either by opening the .R file in the editor or by sourcing it in the console). So I'll ask in the Posit community.

  • FICO's avatar
    FICO
    Community Manager

    In case any other Xpress users trip over this, I found a fix. The problem is that when RStudio is run, it does not see the bash environment variables. I created a text file named ".Renviron" in my home directory (one did not already exist) and added the line "XPAUTH_PATH=/home/paul/Software/XpressMP/bin/xpauth.xpr". This means that RStudio (and the R session it is using) can see the license variable. The other Xpress-related environment variables are not loaded but apparently are not needed.

  • FICO's avatar
    FICO
    Community Manager

    Thanks for posting the answer yourself and helping other users to avoid this common pitfall between R and RStudio. In RStudio you can verify that the environment variable is actually set by executing

    Sys.getenv("XPAUTH_PATH")

    from inside the interactive RStudio terminal. If this returns an empty string, follow Paul's recipe and make sure that RStudio is launched with a valid .Renviron initialization.