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.
If target is a directory, then cp copies one or more source files to that directory keeping the original file names. If a target file does not exist, cp creates it giving it the same permissions as the source file but only allocating as many blocks as required by the contents of the source.
By default, cp does not copy directories. However, the -R , -a , and -r options cause cp to copy recursively by descending into source directories and copying files to corresponding destination directories.
When you specify a single source file and the target is not a directory, mv moves the source to the new name, by a simple rename if possible. If a destination file exists and you do not have write permission for it, mv prompts with the name of the existing file.
cp command copies files (or, optionally, directories). The copy is completely independent of the original. You can either copy one file to another, or copy arbitrarily many files to a destination directory. In the first format, when two file names are given, cp command copies SOURCE file to DEST file.
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!
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With