RStudio安装readxl包失败求助(R 3.4.4/RStudio 1.1.456)
Hey there, let's work through this error you're hitting when trying to install the readxl package. The missing assert.h file is a clear indicator that your system doesn't have the essential C/C++ development libraries required to compile R packages from source—since readxl depends on the utf8 package, which is being built from source here.
Why This Happens
assert.h is a standard header file from the C standard library. When R installs packages from source (like it's trying to do with utf8), it relies on your system having the full set of development tools and libraries installed. If these are missing, the GCC compiler can't find the necessary files to finish compiling the package.
Step-by-Step Solutions
1. Install System-Level Development Tools
First, you need to install the core development packages for your Linux distribution:
For Debian/Ubuntu-based systems:
Open a terminal and run:sudo apt-get update && sudo apt-get install build-essentialThis package includes GCC, standard libraries, and all the tools needed to compile software from source.
For CentOS/RHEL-based systems:
Run either of these commands in a terminal:# Install full development tools group sudo yum groupinstall "Development Tools" # Or install just the glibc development library (which includes assert.h) sudo yum install glibc-devel
2. Reinstall readxl
Once the development tools are installed, go back to RStudio and try installing readxl again:
install.packages("readxl")
This time, the compiler should find assert.h and successfully build the utf8 dependency.
3. Alternative: Install Binary Packages (If Source Compilation Fails)
If you still run into issues (since R 3.4.4 is an older version, some binary repositories might be limited), you can try installing pre-compiled binary versions of the packages directly:
# Install utf8 as a binary first install.packages("utf8", type = "binary") # Then install readxl install.packages("readxl", type = "binary")
Note that binary packages depend on your system's compatibility—this works best if you're using a Linux distribution that provided binary packages for R 3.4.4 at the time.
内容的提问来源于stack exchange,提问作者Edmar Munhoz

