Problems with R CMD INSTALL
I was trying to install a package (ANTsR) by running
R CMD INSTALL as normal on the cloned github repository on a particular cluster. I kept getting errors and could not understand why for the life of me. Note, I have not used this cluster much and wasn't sure how it was configured.
I was pretty sure that this was a configuration problem on the cluster because I had installed this repo on:
- My system
- A shiny server
- Another cluster
Finding the Error
The build was using
cmake, so I figured it was some flag. Oddly enough, I was getting the error (I put
. where thes are hard paths not relevant to you):
-- Check for working C compiler: ./cc -- broken CMake Error at . (message): The C compiler "." is not able to compile a simple test program.
Whoa. Now either the C compiler is broken (unlikely) or the configuration has an error/bug (much more likely). I didn't write the config for this package (it's pretty complex), so I felt a bit at a loss.
Let's look at the error
Well, the error did push me to the log for the error
CMakeFiles/CMakeError.log, let's go there. Looking at the result of
CMakeFiles/CMakeError.log, I found the following areas that seemed like where things were problems:
Build flags: ;WARNING:;ignoring;environment;value;of;R_HOME
Hmm. I see that these are words, not really building flags. They also seem like R code. I don't know how they got there, so I did some Googling.
I got to a page of someone having a similar issue: '“ignoring environment value of R_HOME” error when installing packages'. That sounds like my problem. OK their admin reset
R_HOME and everything is great. Good for him, not much help for me.
I found a bug report for R which discusses this, but there didn't seem to be any resolution.
Finding a Solution
I went back to the simple R warning “WARNING: ignoring environment value of R_HOME” and found an old StackOverflow Post about it.
Now, one thing they discussed was
I tried that, nothing worked.
OK, well what about
RHOME, let's unset that too:
Error, fail. Moreover, these variables were never set anyway. Oh! I realized if we reversed the error, that
R_HOME was set incorrectly, then let's just set it before
R CMD INSTALL and then it shouldn't error:
R_HOME=`R RHOME`; R CMD INSTALL ANTsR
That's not to say the package will install without a hitch, but this part of the build seems to be fixed. (Note: I had to clean out the errors to rerun).
Why did this happen?
I believe most of this happened by the configuration of
R on the cluster and the linking of the
R folder (try
which R) to the true home for
R RHOME). I don't know where (if anywhere) in the setup/.bashrc/.bash_profile scripts
R_HOME is set, but it seems that this discrepancy caused a problem.