install.package(ncdf4) failure

This is on a Mac running Big Sur. My XCode is up-to-date and netcdf4 include files and libraries are installed using MacPorts in /opt/local/{include,lib}. nc-config finds these.

I'm getting the following error message when I run
install.packages(ncdf4). the error reads

checking whether the C compiler works... no
configure: error: in /private/var/folders/dg/18_vnn9n29b_1cj7xkgj9sx00000gn/T/Rtmp84SVp1/R.INSTALL5d5489ba89/ncdf4': configure: error: C compiler cannot create executables See config.log' for more details
ERROR: configuration failed for package ‘ncdf4’

  • removing ‘/Users/whd/Library/R/x86_64/4.1/library/ncdf4’
    Warning in install.packages :
    installation of package ‘ncdf4’ had non-zero exit status

Sorry for such a newbie question, but I can't find config.log. Any help?

TIA

probably means that you do not have the XCode app and its command line tools.

Don’t go there unless you have reasons other than R to be a software developer. Instead,

install.packages(“ncdf4”)

and when you get the option

A binary version is available but the source version is later.

Respond N.

The error message is the result of running

install.packaged("ncdf4")

as my original message said.

And I've had no problem installing other packages.

and

xcode-select --install

gives the message...

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

However, I checked and it appears there is an update to Xcode.

I've upgraded Xcode and I still get the same message.

If someone wants to see the entire output from the

install.packages("ncdf4")

command, let me know and I'll post it. It's long, and generally I don't want to clutter up things unless there's a need.

probably means that the system is trying to install a source file, which requires compilation. That problem won't occur with a binary file installation. Other packages have succeeded most likely because at the time of installation no later source version was available.

sigh

Yes. As I've made clear, ( twice), I know that it's trying to compile a source file.

Given that the netcdf4 libraries exist on my computer, and the configuration messages (which I haven't provided, but which I can, if you want) show that it's looking in the correct place for the include files and the libraries, the mystery is why it's not succeeding.

But, if you know of where I can get a binary for this library, I'll happily entertain installing that. Being a newbie, I don't know how to install anything except through the method which is failing, namely, via the command

install.packages("ncdf4")

I'd like to point out that this command has succeeded in installing packages from source for other libraries, so I'm a bit at a loss as to how to proceed.

Perhaps you can answer this question.

It says

See `config.log' for more details

Where is that file? The directories it mentions don't have it, or they've been deleted by the build process.

Okay. The configuration messages says...

R C compiler used = /opt/local/bin/clang-mp-13

That executable doesn't exist. There is a /opt/local/bin/clang-12 installed by MacPorts.

The 'system' clang is in /usr/bin/clang (installed by Xcode and its `command line' tools) is version 13, if clang --version is anything to go by.

I symlinked /opt/local/bin/clang-mp-13 to /usr/bin/clang and tried again. It still failed, but asked if I wanted to install the Command Line developer tools. (I have installed these, both through Xcode's command 'Xcode-select --install' and by downloading the package for the command line tools and installing that 'by hand', so to speak), but I'm not going to argue with it, so I said yes. It downloaded and installed them (again).

This failure to see Apple's command line developer tools is a common failure for MacPorts; apparently R's 'install.packages(...)' command suffers the same problem.

This webpage discusses issues related to installing packages on a Mac running Big Sur.

Still investigating.

I believe I have the resolution.

Since I had symlinked /opt/local/bin/clang-mp-13 to /usr/bin/clang, that is what occasioned the message that I needed to download and install Xcode's command line developer tools when I tried install.packages(...) the last time but one. However, the compilation still failed.

I saw that MacPorts had a clang-13 variant, so I tried to install that, but the installation failed because of my symlink in /opt/local/bin. I removed that and tried again, the install of clang-13 succeeded, produced a file /opt/local/bin/clang-mp-13.

I tried

install.packaged("ncdf4")

again, and it succeeded!

So, apparently, the clang version 13 that comes with Apple's Xcode doesn't work, but the one that comes with MacPorts does. The posted PDF says the same about Xcode 13.

Don't ask me why.

1 Like

The success illustrates why installation from source on macOS can be problematic for most users. Even though it sometimes succeeds, with as much effort as shown, or more, it often fails. There is no advantage to installing from source over the binary versions other than the hours of enjoyment spent trying to understand, as shown here, the source of the problem. My advice to others is always to check the CRAN page for the package for the pre-compiled (binary) version.

macOS binaries: r-release (arm64): ncdf4_1.19.tgz, r-release (x86_64): ncdf4_1.19.tgz, r-oldrel: ncdf4_1.19.tgz

If those exist, install.packages will proceed smoothly unless the option to install from source in case of a later source version is selected.

Thanks for the information

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.