jaraco / jaraco/cmdix

cp -r fails to create directories

Open
#18 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
30
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Attempting to copy a tree of files using cp -r fails when the first file of a subdirectory doesn't exist in the target:

```
🐚 cp -r out out2
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "C:\Users\coombsjason\.local\bin\cp.exe\__main__.py", line 7, in
File "C:\Users\coombsjason\pipx\venvs\cmdix\Lib\site-packages\cmdix\__init__.py", line 127, in run
return run_subcommand(commandname, argv)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\coombsjason\pipx\venvs\cmdix\Lib\site-packages\cmdix\__init__.py", line 165, in run_subcommand
args.func(args)
File "C:\Users\coombsjason\pipx\venvs\cmdix\Lib\site-packages\cmdix\command\cp.py", line 58, in func
args.handle(_copy, args, dest, src)
File "C:\Users\coombsjason\pipx\venvs\cmdix\Lib\site-packages\cmdix\command\cp.py", line 66, in handle_recursive
walk(_copy, args, dest, src)
File "C:\Users\coombsjason\pipx\venvs\cmdix\Lib\site-packages\cmdix\command\cp.py", line 104, in walk
_copy(srcfile, dstfile)
File "C:\Python312\Lib\shutil.py", line 435, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Python312\Lib\shutil.py", line 262, in copyfile
with open(dst, 'wb') as fdst:
^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '\\build\\Microsoft.NETFramework.ReferenceAssemblies.net45.targets'
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with cmdix/command/cp.py, especially handle_recursive, walk, and the _copy call shown in the traceback. Reproduce `cp -r out out2` with a subdirectory whose first file is absent from the destination, then verify that recursive copying creates the needed directories and completes without FileNotFoundError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.