I am trying to compile R locally using a bash file, but it fails and shows the following error:
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 is the bash file I am submitting:
#!/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/
When I run the same command lines directly on terminal it works fine, but when I try to run them using a bash file it fails.
Does anyone have an idea how to make it work?
The bash instance used to run the script doesn't seem to have the $PATH variable correctly set, so it can't find tar and the other commands.
Try replacing the 1st line with #!/bin/bash -l. Add echo Path: $PATH as the 2nd line and see if one of the directory listed actually contains tar. You should get something like /bin:/sbin:/usr/bin/.
Related
I'm trying to write a Makefile in such a way that all of the steps in my recipe can call scripts a list of directories. As an example, I have node commands that are in a node_modules/.bin directory, but there could just as well be Python commands from a Python virtual environment as well, etc.
I have node installed, as well as TypeScript installed via npm in my /node_modules. Given my directory /tmp/test123, I wrote the following Makefile at /tmp/test123/Makefile as an example:
PATH = /tmp/test123/node_modules/.bin:$(PATH)
.PHONY: compile
compile:
env | grep "PATH"
tsc --help
However, if I try to run it, it outputs:
$ make compile
env | grep "PATH"
PATH=/tmp/test123/node_modules/.bin:... # the rest of my PATH
tsc --help
make: tsc: No such file or directory
make: *** [compile] Error 1
But if I change the last line to cd . && tsc --help, then compile runs successfully.
Why is make unable to find the tsc command in the PATH? Why do I need to run cd . && in front of it? Is there any better workaround than writing cd . && in front of all of my recipe steps?
I created the following makefile to generate a.pdf and then copy it to b.pdf.
all:
arara a.tex
rm *.dvi *.aux *.log
cp a.pdf b.pdf
The first two commands run correctly: meaning a file named a.pdf is generated, and the temporary *.dvi, *.aux, *.log files are removed.
But the cp command does not run: meaning b.pdf is not created. Any idea why? I tried cp -f as well.
(arara is a utility to compile a tex file and generate a pdf file, its details are not important for this question)
The error turned out to be in the rm command and not in the cp command. One of the extensions *.aux did not exist and so rm threw an error. I resolved it by adding -f to the rm command.
For building my target I have a list of prerequisites contained in a file list.txt and a script for generating this file generate-list.sh.
I need the script to be executed as first thing every time I invoke the make in order to have the list.txt updated and to give ti make the right list of prerequisites.
prebuild:
touch list.txt
.SECONDEXPANSION:
exe: prebuild $$(shell cat list.txt)
touch exe
<files in list.txt>:
<rules for generating these files>
In this way when I run make I first get an error from cat saying that list.txt does not exist, then list.txt is generated but since the cat failed the prerequisites contained in list.txt are not generated.
One method you could use, given that generate_list.sh must be executed at the very start every time, would be to explicitly execute it using the shell function. This would mean altering your makefile to something like
$(shell ./generate_list.sh > /dev/null)
.SECONDEXPANSION:
exe: $(shell cat list.txt)
touch exe
#echo $?
<files in list.txt>:
<rules for generating these files>
Executing this makefile produces
$ make
touch exe
deps.c test.c
where my generate_list.sh file contains
#!/bin/bash
touch test.c deps.c
echo deps.c test.c > list.txt
echo 'Created prerequisites list.'
Notes
/dev/null is included in $(shell ./generate_list.sh > /dev/null) incase your generate_list.sh produces an output as this would cause an error in make of
$ make
GNUmakefile:1: *** missing separator. Stop.
otherwise.
#echo $? shows that all of the prerequisites in list.txt are now included as prerequisites of exe.
Alternate Method Based on Auto Dependency Generation
What you are attempting to do is very similar to automatic dependency generation which can be accomplished using the -include directive in make. For future usage you may want to consider going down this route and altering your generate_list.sh script to create a makefile that can be included in your main makefile.
I am having problems with makefile for creating docx file from rmd using R.
Here is my make file, which patially works fine, except last part:
all: ibn_paper.pdf; cabg_n_cor_draft.docx
ibn_paper.md:
Rscript -e "library(knitr); knit('ibn_paper.Rmd')"
ibn_paper.pdf: ibn_paper.md
pandoc -H format.sty -V fontsize=12pt --bibliography ibn_refs.bib ibn_paper.md -o ibn_paper.pdf
cabg_n_cor_draft.docx: ibn_paper.md
pandoc -s -S -V fontsize=12pt --bibliography ibn_refs.bib ibn_paper.md -o
cabg_n_cor_draft.docx
clean:
#-rm -r *.md
And all this code works and creates at the end this error:
make: cabg_n_cor_draft.docx: No such file or directory
make: *** [all] Error 1
Exited with status 2.
How can I solve this problem?
Many thanks beforehand.
Try to remove semicolon in the first line. You probably wanted to let all depend on the two files. But semicolon separates recipe from list of prerequisites.
Look at makefile rule syntax
I am trying to install Boost on an unix cluster machine following the Boost instructions
I downloaded boost_1_43_0.tar.bz2 and was then instructed to execute the following command:
tar --bzip2 -xf /path/to/boost_1_43_0.tar.bz2
However it didn't work and this is the output I get:
tar --bzip2 -xf
/path/to/boost_1_43_0.tar.bz2
tar: /path/to/boost_1_43_0.tar.bz2:
Cannot open: No such file or directory
tar: Error is not recoverable: exiting
now
tar: Child returned status 2
tar: Error exit delayed from previous
errors
You don't literally write /path/to/boost_1_43_0.tar.bz2.
If the archive is in the current directory, you write ./boost_1_43_0.tar.bz2, for instance. Or if you saved it in the /tmp directory, the command would be tar --bzip2 -xf /tmp/boost_1_43_0.tar.bz2.
Instructions that use /path/to/some/file to indicate that you need to use your own path are pretty common. You'll need to be careful about reading the commands before you execute them in the future, too.
By /path/to/boost_1_43_0.tar.bz2 they mean the path to the downloaded file, wherever you happened to save it on your machine. So if you downloaded it in /home/Elpezmuerto, the path would be /home/Elpezmuerto/boost_1_43_0.tar.bz2.