question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cp-Error: dest is not a directory (too many sources)

See original GitHub issue

Node 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:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nfischercommented, Jan 31, 2021

That error message suggests the dist/ folder doesn’t already exist. cp doesn’t know to create that for you, so you need to create that first yourself:

shell.mkdir('dist/'); // this will create "dist/"
shell.cp('-r', 'src/public/', 'dist/'); // this will create "dist/public/"

Alternatively, this works too:

shell.mkdir('dist/');
// this also creates "dist/public/", although you could optionally name it "dist/<whatever you want>/"
shell.cp('-r', 'src/public/', 'dist/public/');
0reactions
nfischercommented, Feb 8, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found