Cp: target is not a directory

I have a bash script with this line:

cp -R /usr/lib/gcc/x86_64-linux-gnu/$GCC_VERSION/* /app/.apt/usr/lib/gcc/x86_64-linux-gnu/$GCC_VERSION 

Full script: https://github.com/virtualstaticvoid/heroku-buildpack-r/blob/cedar-14/bin/compile

Unfortunately it fails with cp: target ‘/app/.apt/usr/lib/gcc/x86_64-linux-gnu/4.8’ is not a directory

Any tips what could be wrong? Unfortunately I do not have much experience with bash.

Previously this script was running alone and it was working. Now I had to add some apt-get install before it, and it started to fail so I am trying to fix it.

1

2 Answers

There is no directory with the name 4.8...Thats your problem :)

Run this before your cp command:

mkdir -p /app/.apt/usr/lib/gcc/x86_64-linux-gnu/$GCC_VERSION 

It creates all directories in the given path!

2

This should work, add / at the end of cp command to make it clear for it that its dir:

mkdir -p /app/.apt cp -R $BUILD_DIR/.apt/* /app/.apt/ 

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJoam9tZmx9eX%2BOnKdmrJGntKbAjKKqZqafqXqiecOiqZ6bpKS%2Fug%3D%3D