无法编译 ‘sass’,当尝试使用R安装包时。

huangapple go评论63阅读模式
英文:

Unable to compile 'sass' when trying to install package with R

问题

当在Rstudio中运行install.packages("sass")时,下载成功,但在编译过程中发生错误:

...
g++ -std=gnu++14 -Wall -O2 -std=c++11 -I /usr/local/lib/libsass/include  -fPIC -c -o src/ast.o src/ast.cpp
In file included from src/ast.cpp:3:
src/sass.hpp:72:43: error: ‘SASS_STYLE_TO_CSS’ was not declared in this scope; did you mean ‘SASS_STYLE_TO_SASS’?
   72 |   const static Sass_Output_Style TO_CSS = SASS_STYLE_TO_CSS;
      |                                           ^~~~~~~~~~~~~~~~~
      |                                           SASS_STYLE_TO_SASS
make[1]: Leaving directory '/tmp/RtmpvBnS6X/R.INSTALLd6174d82af25/sass/src/libsass'
make[1]: *** [Makefile:229: src/ast.o] Error 1
make: *** [Makevars:7: libsass/lib/libsass.a] Error 2
ERROR: compilation failed for package ‘sass’
...

我尝试使用install_github安装rstudio/sass的较早版本,如这里建议的方式,但遇到了相同的编译错误。

(我需要此软件包作为其他软件包的依赖项,尤其是rmarkdown

以下是我的计算机信息(sessionInfo()的输出):

R版本 4.2.3(2023-03-15)
平台:x86_64-pc-linux-gnu(64位)
运行环境:Ubuntu 22.04.2 LTS
...
英文:

When running install.packages("sass") in Rstudio, the download succeeds but an error occurs in the compilation :

...
g++ -std=gnu++14 -Wall -O2 -std=c++11 -I /usr/local/lib/libsass/include  -fPIC -c -o src/ast.o src/ast.cpp
In file included from src/ast.cpp:3:
src/sass.hpp:72:43: error: ‘SASS_STYLE_TO_CSS’ was not declared in this scope; did you mean ‘SASS_STYLE_TO_SASS’?
   72 |   const static Sass_Output_Style TO_CSS = SASS_STYLE_TO_CSS;
      |                                           ^~~~~~~~~~~~~~~~~
      |                                           SASS_STYLE_TO_SASS
make[1]: Leaving directory '/tmp/RtmpvBnS6X/R.INSTALLd6174d82af25/sass/src/libsass'
make[1]: *** [Makefile:229: src/ast.o] Error 1
make: *** [Makevars:7: libsass/lib/libsass.a] Error 2
ERROR: compilation failed for package ‘sass’
...

I have tried to install earlier versions of rstudio/sass with install_github, as advised here, encountering the same compilation error.


(I need this package as a dependency for other ones, notably rmarkdown)

Here is my machine's information (output of sessionInfo()) :

R version 4.2.3 (2023-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS
...

答案1

得分: 1

首先确保您的系统已安装必要的开发工具和库:

sudo apt-get update
sudo apt-get install -y build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev

然后,删除最新版本的 LibSass:

sudo apt-get remove libsass

然后安装它:

git clone https://github.com/sass/libsass.git
cd libsass
git checkout tags/3.6.5  # 如果需要,替换为最新版本
make -j4
sudo make install

现在,在 R 中安装 'sass' 包:

install.packages("sass")

如果仍然无法正常工作,请尝试在 GitHub 上直接安装:

if (!requireNamespace("remotes", quietly = TRUE))
  install.packages("remotes")
remotes::install_github("rstudio/sass")

您还可以尝试使用 R 中的 'devtools' 包安装 'sass' 包:

首先,如果尚未安装 'devtools' 包,请执行以下命令:

install.packages("devtools")

然后加载 'devtools' 包:

library(devtools)

最后,尝试安装 'sass':

devtools::install_github("rstudio/sass")

如果仍然无法正常工作,您可以尝试在 GitHub 上联系他们。

英文:

first make sure you have the necessary development tools and libraries installed on your system with

sudo apt-get update
sudo apt-get install -y build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev

then remove the latest version of LibSass sudo apt-get remove libsass then install it

git clone https://github.com/sass/libsass.git
cd libsass
git checkout tags/3.6.5 # Replace '3.6.5' with the latest version, if necessary
make -j4
sudo make install

now Install the 'sass' package in R install.packages("sass")

if that still dont work try directly on the github

if (!requireNamespace("remotes", quietly = TRUE))
  install.packages("remotes")
remotes::install_github("rstudio/sass")

You can also try by installing the 'sass' package using the 'devtools' package in R:

first install the devtools package if not already install.packages("devtools") then load it library(devtools) and we try to install sass devtools::install_github("rstudio/sass")

if still not maybe reach them on github

答案2

得分: 1

如在这些幻灯片(来自这个博客)中所描述,我能够通过运行以下命令来安装该软件包:

export DEBIAN_FRONTEND=noninteractive
apt update && apt install -y software-properties-common
add-apt-repository -y ppa:c2d4u.team/c2d4u4.0+
echo "deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/" > /etc/apt/sources.list.d/cran.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
apt update && apt install -y r-cran-sass

由于这个PPA,我现在可以使用aptcran镜像安装(任何其他)软件包。

英文:

As described in these slides (from this blog), I was able to install the package running those commands :

export DEBIAN_FRONTEND=noninteractive
apt update && apt install -y software-properties-common
add-apt-repository -y ppa:c2d4u.team/c2d4u4.0+
echo ”deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/” > /etc/apt/sources.list.d/cran.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
apt update && apt install -y r-cran-sass

Thanks to this PPA, I can now install (any other) packages from the cran mirror with apt .

huangapple
  • 本文由 发表于 2023年4月4日 11:13:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75925241.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定