0

I'm running R 3.6.1 in an Anaconda environment (it won't let me upgrade to v4) and trying to install semPlot to accompany lavaan which installed fine. Here are the packages I've installed:

library(psych)   # for Chronbach's alpha calculation
library(psychTools)
library(lavaan)
library(knitr)
library(tidyverse)
library(haven)
library(labelled)
library(kableExtra)
library(survey)
library(srvyr)
library(scales)

I've tried many different ways to install semPlot, the latest was directly from the github repository: SachaEpskamp/semPlot, which one person on stackoverflow said worked for them. After about 10,000 lines of warnings and errors scrolling across my console so fast I couldn't track much of it, this latest attempt produced this at the end:

The downloaded source packages are in
    ‘/private/var/folders/8_/ql9yb6nn4076n1y9vptzpqwm0000gp/T/RtmpvagRhg/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
✓  checking for file ‘/private/var/folders/8_/ql9yb6nn4076n1y9vptzpqwm0000gp/T/RtmpvagRhg/remotes164e53982f159/SachaEpskamp-semPlot-a2ee9df/DESCRIPTION’ ...
─  preparing ‘semPlot’:
✓  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘semPlot_1.1.4.tar.gz’
   
ERROR: dependency ‘OpenMx’ is not available for package ‘semPlot’
* removing ‘/Users/sjgenco/opt/anaconda3/envs/r_env/lib/R/library/semPlot’
Warning messages:
1: In i.p(...) : installation of package ‘OpenMx’ had non-zero exit status
2: In i.p(...) :
  installation of package ‘/var/folders/8_/ql9yb6nn4076n1y9vptzpqwm0000gp/T//RtmpvagRhg/file164e543b3278e/semPlot_1.1.4.tar.gz’ had non-zero exit status

I don't know if OpenMx is the culprit or if OpenMX and semPlot may be suffering from the same problem, but I get the same sort of result when I try to install it ... thousands of lines (and about 20 minutes of fruitless runtime) before it just peters out, not with any kind of error, just a "nonzero exit status".

I've read lots of similar questions here on SO, but most have some dependent package not being found, like glasso or XML a missing fortran compiler, but I have no references like that in my output and I have all those packages installed anyway. I just have reams of output like this (this is from a failed OpenMx installation attempt:

In file included from povRAM.cpp:2:
In file included from ./omxExpectation.h:32:
In file included from ./omxDefines.h:21:
In file included from /Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp.h:27:
In file included from /Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/RcppCommon.h:120:
In file included from /Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/proxy.h:22:
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/NamesProxy.h:32:21: warning: definition of implicit copy constructor for 'NamesProxy' is deprecated because it has a user-declared copy assignment operator [-Wdeprecated-copy]
        NamesProxy& operator=(const NamesProxy& rhs) {
                    ^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/NamesProxy.h:83:16: note: in implicit copy constructor for 'Rcpp::NamesProxyPolicy<Rcpp::Vector<19, PreserveStorage> >::NamesProxy' first required here
        return NamesProxy( static_cast<CLASS&>(*this) ) ;
               ^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/api/meat/module/Module.h:35:11: note: in instantiation of member function 'Rcpp::NamesProxyPolicy<Rcpp::Vector<19, PreserveStorage> >::names' requested here
            info.names() = names ;
                 ^
In file included from povRAM.cpp:3:
In file included from ./path.h:6:
./polynomial.h:26:2: warning: definition of implicit copy assignment operator for 'Monomial<double>' is deprecated because it has a user-declared copy constructor [-Wdeprecated-copy]
        Monomial(const Monomial<F> &from) { coeff = from.coeff; exponent = from.exponent; }
        ^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/bin/../include/c++/v1/__tree:1691:39: note: in implicit copy assignment operator for 'Monomial<double>' first required here
            __cache.__get()->__value_ = *__first;
                                      ^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/bin/../include/c++/v1/__tree:1648:9: note: in instantiation of function template specialization 'std::__1::__tree<Monomial<double>, std::__1::less<Monomial<double> >, std::__1::allocator<Monomial<double> > >::__assign_multi<std::__1::__tree_const_iterator<Monomial<double>, std::__1::__tree_node<Monomial<double>, void *> *, long> >' requested here
        __assign_multi(__t.begin(), __t.end());
        ^
/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/bin/../include/c++/v1/set:538:21: note: in instantiation of member function 'std::__1::__tree<Monomial<double>, std::__1::less<Monomial<double> >, std::__1::allocator<Monomial<double> > >::operator=' requested here
            __tree_ = __s.__tree_;
                    ^
./polynomial.h:183:13: note: in instantiation of member function 'std::__1::set<Monomial<double>, std::__1::less<Monomial<double> >, std::__1::allocator<Monomial<double> > >::operator=' requested here
                monomials = erg.monomials;
                          ^
povRAM.cpp:299:16: note: in instantiation of member function 'Polynomial<double>::operator+=' requested here
                        polyRep[nn] += term;
                                    ^
95 warnings and 7 errors generated.
make: *** [/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/etc/Makeconf:175: povRAM.o] Error 1
ERROR: compilation failed for package ‘OpenMx’
* removing ‘/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/OpenMx’
Warning in install.packages :
  installation of package ‘OpenMx’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/8_/ql9yb6nn4076n1y9vptzpqwm0000gp/T/Rtmp8fpYnY/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done

A warning that comes up again and again in all these outputs is this:

warning: definition of implicit copy constructor ...

as in:

/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/NamesProxy.h:32:21: warning: definition of implicit copy constructor for 'NamesProxy' is deprecated because it has a user-declared copy assignment operator [-Wdeprecated-copy]
        NamesProxy& operator=(const NamesProxy& rhs) {
                    ^

or this

/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/proxy/AttributeProxy.h:33:25: warning: definition of implicit copy constructor for 'AttributeProxy' is deprecated because it has a user-declared copy assignment operator [-Wdeprecated-copy]
            AttributeProxy& operator=(const AttributeProxy& rhs){
                            ^

or this

/Users/xxxxxxxxx/opt/anaconda3/envs/r_env/lib/R/library/RcppEigen/include/Eigen/src/SparseCore/SparsePermutation.h:162:1: note: candidate template ignored: could not match 'InverseImpl' against 'Transpose'
operator*(const SparseMatrixBase<SparseDerived>& matrix, const InverseImpl<PermutationType, PermutationStorage>& tperm)
^
povRAM.cpp:157:24: error: use of undeclared identifier 'curProd'
                        if (tx == 1) prev = curProd.nonZeros();
                                            ^

This is just a big mess and I have no idea what's happening, why, or what to do about it. Any thoughts?

steve---g
  • 365
  • 2
  • 11
  • What OS is this? Is it a mac? Try `install.packages("OpenMx", type="binary")`. The warnings don't matter when compiling, what matters are the errors. Anaconda seems to cause all sorts of trouble for people compiling their own packages. Is it really necessary you use anaconda for R? It would probably be much easier if you installed R with the official installer. – MrFlick Jun 30 '21 at 05:00
  • 1
    To add to @MrFlick's comment, you could try installing OpenMX via conda. If you don't have the conda-forge channel, add it to your env with `conda config --add channels conda-forge` then try installing OpenMX using `conda install -c conda-forge r-openmx`. – jared_mamrot Jun 30 '21 at 05:02

2 Answers2

1

Your problems are likely caused by running R through Anaconda. Following these steps I successfully install OpenMX and semPlot without error on macOS 11.4 / Rv4.0, but you'll have to try it to find out if they will work on 'conda' R3.6.3.

  1. Install xcode from the app store (instructions for installing xcode) then install/reinstall the xcode command line tools from the terminal:
# To delete an existing command line tools installation:
sudo rm -rf /Library/Developer/CommandLineTools

# To install the command line tools
sudo xcode-select --install
  1. Install gcc & llvm via Homebrew (instructions for installing Homebrew) or, if you already have gcc and llvm installed, skip to step 3.
# WARNING: This can take several hours
brew install gcc
brew install llvm
  1. If you already have gcc & llvm installed via Homebrew:
brew cleanup
brew update
brew upgrade
brew reinstall gcc
brew reinstall llvm
  1. Link some headers into /usr/local/include
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/

# You can ignore warnings like this:
#ln: /usr/local/include//tcl.h: File exists
#ln: /usr/local/include//tclDecls.h: File exists
#ln: /usr/local/include//tclPlatDecls.h: File exists
#ln: /usr/local/include//tclTomMath.h: File exists
#ln: /usr/local/include//tclTomMathDecls.h: File exists
#ln: /usr/local/include//tk.h: File exists
#ln: /usr/local/include//tkDecls.h: File exists
#ln: /usr/local/include//tkPlatDecls.h: File exists
  1. Check your version of gfortran (cd /usr/local/gfortran/lib/gcc/x86_64-apple-darwin19/; ls) then edit your ~/.R/Makevars file (if you don't have a file called Makevars in your ~/.R/ directory, or the 'conda' R equivalent directory, create it) and include only these lines:
LOC = /usr/local/gfortran
CC=$(LOC)/bin/gcc -fopenmp
CXX=$(LOC)/bin/g++ -fopenmp
CXX11 = $(LOC)/bin/g++ -fopenmp

CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib
CPPFLAGS=-I$(LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include

# (check that the version of gfortran - in this case 10.2.0 - matches the version specified in FLIBS)
FLIBS=-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin19/10.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
CXX1X=/usr/local/gfortran/bin/g++
CXX98=/usr/local/gfortran/bin/g++
CXX11=/usr/local/gfortran/bin/g++
CXX14=/usr/local/gfortran/bin/g++
CXX17=/usr/local/gfortran/bin/g++
  1. Open R and install the packages (when asked, compile from source = "Yes"):
install.packages("qgraph")
install.packages("OpenMx")
devtools::install_github("SachaEpskamp/semPlot")

Then, hopefully, things will load as they are supposed to.

jared_mamrot
  • 22,354
  • 4
  • 21
  • 46
1

Thank you for this detailed advice. First I tried to fix it inside my Anaconda environment by running the conda forge installation in my r_env from the terminal. It installed, but it also managed to break my RStudio installation so that wouldn't open anymore. OK, lesson learned. I deleted my whole r_env in Anaconda and proceeded to follow @MrFlick's advice to install clean new versions of R and RStudio from their official download sites. When I opened my fresh RStudio app, I was able to install semPlot, which installed its dependency OpenMx without a hitch. Back in business.

steve---g
  • 365
  • 2
  • 11