njtierney / maxcovr

Tools in R to make it easier to solve the Maximal Coverage Location Problem
https://maxcovr.njtierney.com/
GNU General Public License v3.0
43 stars 12 forks source link

getting Gurobi to run outside of RStudio #39

Open njtierney opened 7 years ago

njtierney commented 7 years ago

Had this problem where Gurobi would run fine inside RStudio, but then it wouldn't work if I can an RScript or called knitr.

I could run library(gurobi) inside RStudio, but when I knitted a chunk, it couldn't load it

So I googled my error message:

error in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/Users/tierneyn/Library/R/3.3/library/gurobi/libs/gurobi.so

And then Found an answer on google groups with a nigh identical error: https://groups.google.com/forum/#!topic/gurobi/p7oZbXcueBM

They said:

I found there's an environmental variable in R called DYLD_FALLBACK_LIBRARY_PATH. It contains different values in RStudio than straight R, but in both cases /Library/Frameworks/R.framework/Resources/lib is present. Copying the libgurobi65.so file to this directory solved the problem.

If anyone has a solution that doesn't involve copying the file, or can explain why this happened, I'd be curious to hear.

I've done this, and it means that I can call the library of Gurobi, but I still can't run the functions inside maxcovr.

This is rather frustrating, and really weird behaviour to replicate. It might be something to do with RStudio, but it might also have something to do with Gurobi

njtierney commented 6 years ago

This should form a vignette in version 0.2.0, that might also describe how to use others solvers