R(v3.5.3)从GitHub安装webr包遇依赖运算符错误,求解决方案
I’ve run into similar dependency parsing headaches with older R versions before, so here are some practical, actionable solutions tailored to your situation:
1. Manually Clone the Repo and Fix the DESCRIPTION File
The core issue is that your outdated R 3.5.3 doesn’t recognize the modern dependency syntax used in the GitHub repo’s DESCRIPTION file. Here’s how to work around it:
- First, clone the repository to your local machine (install
git2rif you don’t have it already):install.packages("git2r") git2r::clone("https://github.com/cardiomoon/webr.git") # Alternatively, use your system's Git command line: git clone https://github.com/cardiomoon/webr.git - Navigate to the cloned folder, open the
DESCRIPTIONfile, and scan for lines inDepends,Imports, orSuggeststhat use syntax likeggplot2 >= 3.0.0. Rewrite these to the old-R-compatible format:ggplot2 (>= 3.0.0)(wrap the version constraint in parentheses). - Install the modified local package:
devtools::install_local("path/to/your/cloned/webr/directory")
2. Downgrade devtools to a Version Optimized for Old R
Even though you’re running the latest devtools, newer versions are built for modern R releases. Try reverting to devtools 1.13.6—this version handled legacy dependency syntax much better:
# Uninstall current devtools first remove.packages("devtools") # Install the older, compatible version library(devtools) install_version("devtools", version = "1.13.6", repos = "http://cran.us.r-project.org") # Now attempt installing the GitHub webr package again devtools::install_github("cardiomoon/webr")
3. Upgrade Your R Version (Most Permanent Fix)
R 3.5.3 is quite dated (released in 2019), and most modern packages have dropped support for its strict dependency parsing rules. If you can afford to upgrade to R 4.0 or later, this will not only resolve this specific error but also prevent a host of other compatibility issues down the line. Once upgraded, installing the GitHub webr package should work without hitches.
4. Extract Just the PieDonut() Function
If you only need the PieDonut() function and want to skip full package installation, you can grab the function code directly:
- Go to the webr repo’s R folder and open
PieDonut.R. - Copy the entire function definition into your R console or script.
- Run the code to define the function in your environment—you’ll be able to use it immediately without installing the full package.
内容的提问来源于stack exchange,提问作者LeBasti

