You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows10下R无法安装GitHub包(非curl问题)求助

Troubleshooting GitHub Package Installation Failure on Windows 10

Hey there, let’s work through this frustrating issue you’re having with installing GitHub packages like xaringan. The weird ÿþ error and ignored path segment in your output points to an encoding conflict or path handling issue tied to your username containing a space (Yue Hu_local), which often trips up R’s temporary file processes on Windows.

Here are targeted fixes to try, ordered from simplest to more involved:

1. Use a Space-Free Temporary Directory

The temporary path generated during installation includes your username with a space, which is likely causing the encoding glitch. Let’s override the temp directory to one without spaces:

# Create a space-free temp folder if it doesn't exist
dir.create("C:/R_Temp", showWarnings = FALSE)
# Set R to use this folder for temp files
Sys.setenv(TMP = "C:/R_Temp")
Sys.setenv(TEMP = "C:/R_Temp")
# Try installing xaringan again
devtools::install_github('yihui/xaringan')

Make sure your user account has write permissions for C:/R_Temp.

2. Fix Encoding Mismatches

The ÿþ character is a UTF-16 byte order mark (BOM), indicating a conflict between your system locale and R’s encoding settings. Let’s align everything to UTF-8:

  • In RStudio, go to Tools > Global Options > Code > Saving and set "Default text encoding" to UTF-8.
  • Add these lines to your .Rprofile (open it with usethis::edit_r_profile()) to enforce UTF-8 locale on startup:
    Sys.setlocale(category = "LC_ALL", locale = "English_United States.UTF-8")
    
  • Restart RStudio completely before attempting the installation again.

3. Install from Source Manually

If the above doesn’t work, bypass devtools’ temp file handling entirely:

  1. Download the source zip of xaringan directly from its GitHub repo.
  2. Unzip it to a space-free directory (e.g., C:/xaringan_source).
  3. Run this command in R:
    install.packages("C:/xaringan_source", repos = NULL, type = "source")
    

4. Double-Check Rtools Configuration

Even though devtools::has_devel() returns TRUE, confirm Rtools is correctly in your system PATH:

  • Run Sys.getenv("PATH") in R. Look for paths like C:/Rtools/bin and C:/Rtools/mingw_64/bin near the top of the output.
  • If they’re missing, add them via Windows’ System Properties > Advanced > Environment Variables (edit the Path variable for your user account).

A quick side note: You’re using R 3.4.3, which is quite old. While you mentioned trying different versions, upgrading to the latest stable R version (paired with the matching Rtools release) might resolve underlying encoding bugs that were fixed in newer updates.


内容的提问来源于stack exchange,提问作者sammo3182

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:33:01