Reinstalling odbc on R 4.0 on Linux RHEL 7

I recently updated my R on my EC2/Redhat 7 to R 4.0.2 (from R 3.6.0) so I have to reinstall packages, an I am having trouble installing odbc.

When I try to run the normal install.packages("odbc"), I get the following error:

nanodbc/nanodbc.cpp:40:19: fatal error: codecvt: No such file or directory
 #include <codecvt>
                   ^
compilation terminated.
make: *** [nanodbc.o] Error 1
ERROR: compilation failed for package ‘odbc’

Does anyone know how I can fix this issue?

The default version of gcc on RHEL 7 (4.8.5) is too old to compile that - full support for <codecvt> was added in gcc 5.

I'd recommend either installing a precompiled odbc binary from https://packagemanager.rstudio.com (this is built with a newer gcc):

install.packages("odbc", repos = "https://packagemanager.rstudio.com/cran/__linux__/centos7/latest")

Or installing the Red Hat Developer Toolset on your system to get a newer gcc: https://www.softwarecollections.org/en/scls/rhscl/devtoolset-8/

3 Likes

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

Thank you! The packagemanager way worked!

Two further comments:

  1. Packagemanager seems to be awesome -- I was also having an error installing xgboost, and I just used the exact same thing, and it worked!
  2. I first tried to install the toolset, but that did not work - I got an error This system is not registered with an entitlement server. You can use subscription-manager to register., but I don't really understand what that means.

Anyway -- thanks!

2 Likes
  1. Oh yeah, AWS has their own set of RHEL repositories that you have to use. Try it with the rhel-server-rhui-rhscl-7-rpms repo:
sudo yum-config-manager --enable rhel-server-rhui-rhscl-7-rpms
sudo yum install devtoolset-8

Then you can test that it worked with:

$ source scl_source enable devtoolset-8
$ gcc --version
gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)

The Developer Toolset has to be manually enabled with every session, but you can permanently enable it using a startup file like this: https://access.redhat.com/solutions/527703.

Since that's kind of a pain, I'd still recommend using packagemanager.rstudio.com binaries if you can.

1 Like

Yes, but you'll have to set packagemanager.rstudio.com as your default CRAN repo, or it'll still update packages from the default CRAN mirror. In RStudio, you can set this through the Packages options - see "Using Packages Inside RStudio" on this page for an example: https://packagemanager.rstudio.com/client/#/repos/1/overview

1 Like

Still didn't work...but I definitely plan on using the packagemanager binaries when I can.

When a version that I installed through the packagemanager gets updated, will I still be able to update it like I normally do (through the pane in RStudio)?