通过bash文件在本地编译R时出错

时间:2017-12-03 20:14:55

标签: r linux bash

我正在尝试使用bash文件在本地编译R,但它失败并显示以下错误:

tar: command not found
cd: R-3.2.5: No such file or directory
./configure: No such file or directory
make: *** No targets specified and no makefile found.  Stop.
make: *** No rule to make target `install'.  Stop.
R-3.2.5/lib64/R/bin/R: No such file or directory
sed: command not found
mv: command not found
tar: command not found

Bellow是我提交的bash文件:

#!/bin/bash
tar -xzvf R-3.2.5.tar.gz
cd R-3.2.5
./configure --prefix=$(pwd)
make
make install
cd ..
R-3.2.5/lib64/R/bin/R -e 'install.packages(c("BGLR"), 
repos="http://cran.cnr.berkeley.edu/", dependencies = TRUE)'
sed -i '/^R_HOME_DIR=/c R_HOME_DIR=$(pwd)/R' R-3.2.5/lib64/R/bin/R
mv R-3.2.5/lib64/R ./
tar -czvf R.tar.gz R/

当我在终端上直接运行相同的命令行时,它工作正常,但是当我尝试使用bash文件运行它时,它会失败。

有没有人知道如何让它发挥作用?

1 个答案:

答案 0 :(得分:0)

用于运行脚本的bash实例似乎没有正确设置$PATH变量,因此无法找到tar和其他命令。

尝试用#!/bin/bash -l替换第一行。添加echo Path: $PATH作为第二行,并查看列出的目录之一是否实际包含tar。你应该得到类似/bin:/sbin:/usr/bin/的东西。

相关问题