<#6359 [BUG] Permission Denied When FlyteKit Build...
# flyte-github
c
#6359 [BUG] Permission Denied When FlyteKit Builds Image Issue created by Sovietaced ### Describe the bug It appears that the default image builder can encounter a permission denied error when its tries to copy the same file more than once.
Copy code
src <redacted>/controller_timing_clk_nb.so is 0o100555
dst <redacted>/controller_timing_clk_nb.so is 0o40775
src <redacted>/msg/__init__.py is 0o100555
dst <redacted>/msg/__init__.py is 0o40775
src <redacted>/msg/__init__.py is 0o100555
dst <redacted>/msg/__init__.py is 0o40775

permission denied happens here
Copy code
│ <redacted>/rules_python~~pip~pip_310_flytekit/site-packages/flytekit/image_spec/default_build │
│ er.py:357 in build_image                                                                         │
│                                                                                                  │
│   354 │   }                                                                                      │
│   355 │                                                                                          │
│   356 │   def build_image(self, image_spec: ImageSpec) -> str:                                   │
│ ❱ 357 │   │   return self._build_image(                                                          │
│   358 │   │   │   image_spec,                                                                    │
│   359 │   │   │   push=os.getenv("FLYTE_PUSH_IMAGE_SPEC", "True").lower() in ("true", "1"),      │
│   360 │   │   )                                                                                  │
│                                                                                                  │
│ <redacted>/rules_python~~pip~pip_310_flytekit/site-packages/flytekit/image_spec/default_build │
│ er.py:376 in _build_image                                                                        │
│                                                                                                  │
│   373 │   │                                                                                      │
│   374 │   │   with tempfile.TemporaryDirectory() as tmp_dir:                                     │
│   375 │   │   │   tmp_path = Path(tmp_dir)                                                       │
│ ❱ 376 │   │   │   create_docker_context(image_spec, tmp_path)                                    │
│   377 │   │   │                                                                                  │
│   378 │   │   │   command = [                                                                    │
│   379 │   │   │   │   "docker",                                                                  │
│                                                                                                  │
│ <redacted>/rules_python~~pip~pip_310_flytekit/site-packages/flytekit/image_spec/default_build │
│ er.py:251 in create_docker_context                                                               │
│                                                                                                  │
│   248 │   │   for file_to_copy in ls:                                                            │
│   249 │   │   │   rel_path = os.path.relpath(file_to_copy, start=str(image_spec.source_root))    │
│   250 │   │   │   Path(source_path / rel_path).parent.mkdir(parents=True, exist_ok=True)         │
│ ❱ 251 │   │   │   shutil.copy(                                                                   │
│   252 │   │   │   │   file_to_copy,                                                              │
│   253 │   │   │   │   source_path / rel_path,                                                    │
│   254 │   │   │   )                                                                              │
│                                                                                                  │
│ <redacted>/rules_python~~python~pyt │
│ hon_3_10_x86_64-unknown-linux-gnu/lib/python3.10/shutil.py:417 in copy                           │
│                                                                                                  │
│    414 │   """                                                                                   │
│    415 │   if os.path.isdir(dst):                                                                │
│    416 │   │   dst = os.path.join(dst, os.path.basename(src))                                    │
│ ❱  417 │   copyfile(src, dst, follow_symlinks=follow_symlinks)                                   │
│    418 │   copymode(src, dst, follow_symlinks=follow_symlinks)                                   │
│    419 │   return dst                                                                            │
│    420                                                                                           │
│                                                                                                  │
│ <redacted>/rules_python~~python~pyt │
│ hon_3_10_x86_64-unknown-linux-gnu/lib/python3.10/shutil.py:256 in copyfile                       │
│                                                                                                  │
│    253 │   else:                                                                                 │
│    254 │   │   with open(src, 'rb') as fsrc:                                                     │
│    255 │   │   │   try:                                                                          │
│ ❱  256 │   │   │   │   with open(dst, 'wb') as fdst:                                             │
│    257 │   │   │   │   │   # macOS                                                               │
│    258 │   │   │   │   │   if _HAS_FCOPYFILE:                                                    │
│    259 │   │   │   │   │   │   try:                                                              │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
PermissionError: [Errno 13] Permission denied:
'<redacted>/msg/__init__.py'
### Expected behavior I would expect that image building succeeds. When I update flytekit so skip copying the same file more than once image building succeeds. ### Additional context to reproduce No response ### Screenshots No response ### Are you sure this issue hasn't been raised already? • Yes ### Have you read the Code of Conduct? • Yes flyteorg/flyte