cp-Error: dest is not a directory (too many sources)
See original GitHub issueNode version (or tell us if you’re using electron or some other framework):
node -v v12.16.1
ShellJS version (the most recent version/Github branch you see the bug on):
0.8.4
Operating system:
Windows & Linux (Docker Node:10.21.0-buster)
Description of the bug:
We try to use the cp command for a bigger amount of files in a deep Folder structure (~8900 files). It returns with exit code 1 and error message cp: dest is not a directory (too many sources). It only crashes, if the whole tree has to be copied. If most of the files are already there and it has to move only a few missing ones, it still works on that source-directory.
At the moment it’s not possible to use shelljs for our folder tree. This result is also equal on both OS - windows and unix. If we do not use shelljs, but the bash command cp for the same directory, that works without any problem. I guess it might be some memory or javascript problem, but could not figure out.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Failed Installation iOS - cp: dest is not a directory (too ... - GitHub
Unable to apply changes on device: 9B71C377-5274-4B96-93D0-B51E687E64B1. Error is: cp: dest is not a directory (too many sources).
Read more >cp-Error: dest is not a directory (too many sources)
It returns with exit code 1 and error message cp: dest is not a directory (too many sources) . It only crashes, if...
Read more >cp behaves weirdly when . (dot) or .. (dot dot) are the source ...
When you run cp -R src/foo dest , you'll get dest/foo . So if directory dest/foo does not exist, cp will create it,...
Read more >command line - cp error in script - Ask Ubuntu
One of the main errors is that you're trying to use the ls command, but the variable LIST only contains the string 'ls'....
Read more >Cp: target is not a directory - Stack Overflow
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!
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

That error message suggests the
dist/folder doesn’t already exist.cpdoesn’t know to create that for you, so you need to create that first yourself:Alternatively, this works too:
It seems like
shell.cp()is working as expected, so I’m going to close this. Let me know if you have any suggestions for whether this needs to be clarified in documentation.