问题描述
我用李东风老师制作的中文图书模板写了一本简单的中文书,直接点击Rstudio右上角的publish按钮,想以html的形式上传到自己的book.org,但是遇到如下问题。
运行结果
问题1:
根据报错我自己判断好像是因为缺少textshaping包,导致最后说“多字节字符串有错”。但是已经下载到了library文件夹,同时找不到fribidi包。为简洁说明,我直接贴出error message和warning message。
[Connect] 2023/04/12 02:45:54.492774266 [1] "Command failed (1)\n\nFailed to run system command:\n\n\t'/opt/R/3.6.2/lib/R/bin/R' --vanilla CMD INSTALL --preclean '/opt/rstudio-connect/mnt/tmp/RtmpA2twbs/packrat-install-5a5774df2baf/textshaping' --library='/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.6.2' --install-tests --no-docs --no-multiarch --no-demo \n\nThe command failed with output:\n* installing source package ‘textshaping’ ...\n** package ‘textshaping’ successfully unpacked and MD5 sums checked\n** using staged installation\nPackage fribidi was not found in the pkg-config search path.\nPerhaps you should add the directory containing fribidi.pc'\nto the PKG_CONFIG_PATH environment variable\nNo package 'fribidi' found\nUsing PKG_CFLAGS=\nUsing PKG_LIBS=-lfreetype -lharfbuzz -lfribidi -lpng\n--------------------------- [ANTICONF] --------------------------------\nConfiguration failed to find the harfbuzz freetype2 fribidi library. Try installing:\n * deb: libharfbuzz-dev libfribidi-de
[Connect] v (Debian, Ubuntu, etc)\n * rpm: harfbuzz-devel fribidi-devel (Fedora, EPEL)\n * csw: libharfbuzz_dev libfribidi_dev (Solaris)\n * brew: harfbuzz fribidi (OSX)\nIf harfbuzz freetype2 fribidi is already installed, check that 'pkg-config' is in your\nPATH and PKG_CONFIG_PATH contains a harfbuzz freetype2 fribidi.pc file. If pkg-config\nis unavailable you can set INCLUDE_DIR and LIB_DIR manually via:\nR CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'\n-------------------------- [ERROR MESSAGE] ---------------------------\n<stdin>:1:10: fatal error: hb-ft.h: No such file or directory\ncompilation terminated.\n--------------------------------------------------------------------\nERROR: configuration failed for package ‘textshaping’\n* removing ‘/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.6.2/textshaping’"
[Connect] 2023/04/12 02:45:54.494743145 Error: Command failed (1)
[Connect] 2023/04/12 02:45:54.494752457
[Connect] 2023/04/12 02:45:54.494783089 Failed to run system command:
[Connect] 2023/04/12 02:45:54.494784293
[Connect] 2023/04/12 02:45:54.494804077 '/opt/R/3.6.2/lib/R/bin/R' --vanilla CMD INSTALL --preclean '/opt/rstudio-connect/mnt/tmp/RtmpA2twbs/packrat-install-5a5774df2baf/textshaping' --library='/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.6.2' --install-tests --no-docs --no-multiarch --no-demo
[Connect] 2023/04/12 02:45:54.494805312
[Connect] 2023/04/12 02:45:54.494818812 The command failed with output:
[Connect] 2023/04/12 02:45:54.494819766 * installing *source* package ‘textshaping’ ...
[Connect] 2023/04/12 02:45:54.494827266 ** package ‘textshaping’ successfully unpacked and MD5 sums checked
[Connect] 2023/04/12 02:45:54.494828394 ** using staged installation
[Connect] 2023/04/12 02:45:54.494835655 Package fribidi was not found in the pkg-config search path.
[Connect] 2023/04/12 02:45:54.494836974 Perhaps you should add the directory containing
fribidi.pc'
[Connect] 2023/04/12 02:45:54.494843995 to the PKG_CONFIG_PATH environment variable
[Connect] 2023/04/12 02:45:54.494845139 No package 'fribidi' found
[Connect] 2023/04/12 02:45:54.494852606 Using PKG_CFLAGS=
[Connect] 2023/04/12 02:45:54.494853486 Using PKG_LIBS=-lfreetype -lharfbuzz -lfribidi -lpng
[Connect] 2023/04/12 02:45:54.494860396 --------------------------- [ANTICONF] --------------------------------
[Connect] 2023/04/12 02:45:54.494861120 Configuration failed to find the harfbuzz freetype2 fribidi library. Try installing:
[Connect] 2023/04/12 02:45:54.494868246 * deb: libharfbuzz-dev libfribidi-dev (Debian, Ubuntu, etc)
[Connect] 2023/04/12 02:45:54.494868927 * rpm: harfbuzz-devel fribidi-devel (Fedora, EPEL)
[Connect] 2023/04/12 02:45:54.494875945 * csw: libharfbuzz_dev libfribidi_dev (Solaris)
[Connect] 2023/04/12 02:45:54.494876582 * brew: harfbuzz fribidi (OSX)
[Connect] 2023/04/12 02:45:54.494883071 If harfbuzz freetype2 fribidi is already installed, check that 'pkg-config' is in your
[Connect] 2023/04/12 02:45:54.494883704 PATH and PKG_CONFIG_PATH contains a harfbuzz freetype2 fribidi.pc file. If pkg-config
[Connect] 2023/04/12 02:45:54.494890275 is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
[Connect] 2023/04/12 02:45:54.494891249 R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
[Connect] 2023/04/12 02:45:54.494897935 -------------------------- [ERROR MESSAGE] ---------------------------
[Connect] 2023/04/12 02:45:54.494898551 <stdin>:1:10: fatal error: hb-ft.h: No such file or directory
[Connect] 2023/04/12 02:45:54.494905176 compilation terminated.
[Connect] 2023/04/12 02:45:54.494905826 --------------------------------------------------------------------
[Connect] 2023/04/12 02:45:54.494912210 ERROR: configuration failed for package ‘textshaping’
[Connect] 2023/04/12 02:45:54.494912920 * removing ‘/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.6.2/textshaping’
[Connect] 2023/04/12 02:45:54.494919516
[Connect] 2023/04/12 02:45:54.494920110 Unable to fully restore the R packages associated with this deployment.
[Connect] 2023/04/12 02:45:54.494926346 Please review the preceding messages to determine which package
[Connect] 2023/04/12 02:45:54.494927000 encountered installation difficulty and the cause of the failure.
[Connect] 2023/04/12 02:45:54.504290549 Warning message:
[Connect] 2023/04/12 02:45:54.504500788 In packrat::restore(overwrite.dirty = TRUE, prompt = FALSE, restart = FALSE) :
[Connect] 2023/04/12 02:45:54.504505763 The most recent snapshot was generated using R version 4.2.3
[Connect] An error occurred while building your content.
[Connect] This link offers advice for this kind of error:
[Connect] https://docs.posit.co/connect/user/troubleshooting/#r-missing-system-library
[Connect] Build error: An error occurred while building your content. (Error code: r-missing-system-library)
Site deployment failed with error: An error occurred while building your content. (Error code: r-missing-system-library)
Warning message:
Error detecting locale: Error in make.names(col.names, unique = TRUE): '<d6><f7><bb><fa>'多字节字符串有错
(Using default: en_US)
我想过可能是输入数据时导入格式不对,就将导入数据的格式改成如下,在原来的基础上添加encoding = "UTF-8":
library(haven)
netizen <- read_stata("eman.dta", encoding = "UTF-8")
但上传的时候还是显示一样的报错信息。
问题2:
在Markers界面,显示如下信息。
0101-usage.Rmd
Line 48 Paths should be to files within the project directory
我回到Rmd文件“0101-usage.Rmd”的第48行,是数据导入部分,如下所示。
library(haven)
netizen <- read_stata("eman.dta")
dput("netizen")
我的数据文件eman.dta是放在和“CBook.Rproj”同一个文件夹中的,不清楚错误在哪。
我的系统环境
sessionInfo()
R version 4.2.3 (2023-03-15 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)China.utf8 LC_CTYPE=Chinese (Simplified)China.utf8
[3] LC_MONETARY=Chinese (Simplified)China.utf8 LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)China.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] rstudioapi_0.14 knitr_1.42 magrittr_2.0.3 tidyselect_1.2.0 R6_2.5.1
[6] rlang_1.1.0 fastmap_1.1.1 fansi_1.0.4 skimr_2.1.5 dplyr_1.1.1
[11] tools_4.2.3 xfun_0.38 utf8_1.2.3 cli_3.6.1 jquerylib_0.1.4
[16] htmltools_0.5.5 askpass_1.1 openssl_2.0.6 yaml_2.3.7 digest_0.6.31
[21] tibble_3.2.1 lifecycle_1.0.3 bookdown_0.33 repr_1.1.6 base64enc_0.1-3
[26] vctrs_0.6.1 rsconnect_0.8.29 curl_5.0.0 glue_1.6.2 evaluate_0.20
[31] rmarkdown_2.21 compiler_4.2.3 pillar_1.9.0 generics_0.1.3 jsonlite_1.8.4
[36] pkgconfig_2.0.3