dvc: Invalid permisions of /var/tmp/dvc/repo

Edited by @shcheklein : See the latest comments, need some research to support the latest platformdirs (?)

Bug Report

dvc ls: creates /var/tmp/dvc with incorrect permissions

Description

Since https://github.com/iterative/dvc/releases/tag/2.48.0 the dvc is using /var/tmp/dvc as a “git cache” for unix based operating systems. When the /var/tmp/dvc does not exist the dvc creates site cache folder using os.makedirs with default 777 permissions, but these permissions are masked by UMASK (https://stackoverflow.com/a/5231994). This can cause an unexpected behavior of dvc ls (an other commands) for multi-user environment where other users can not write to originally created site-cache folder

https://github.com/iterative/dvc/blob/612f3039e05b609d02d96c063763f8c093c2779d/dvc/repo/__init__.py#L212

Reproduce

  1. remove site cache dir rm -r -f /var/tmp/dvc
  2. run dvc ls dvc ls git@github.com:iterative/dvc-test.git
  3. check permissions ls -al /var/tmp/dvc or run 2) as a different user

Expected

I believe that the site cache dir should be created with permissions that allows other users to list dvc repositories.

Environment information

Centos8

╰─❯ dvc doctor
DVC version: 2.48.0 (pip)
-------------------------
Platform: Python 3.8.13 on Linux-4.18.0-408.el8.x86_64-x86_64-with-glibc2.2.5
Subprojects:
	dvc_data = 0.43.0
	dvc_objects = 0.21.1
	dvc_render = 0.2.0
	dvc_task = 0.2.0
	scmrepo = 0.1.15
Supports:
	http (aiohttp = 3.8.1, aiohttp-retry = 2.8.3),
	https (aiohttp = 3.8.1, aiohttp-retry = 2.8.3),
	s3 (s3fs = 2023.1.0, boto3 = 1.24.59)
Cache types: reflink, hardlink, symlink
Cache directory: xfs on /dev/md0
Caches: local
Remotes: s3
Workspace directory: xfs on /dev/md0
Repo: dvc, git
Repo.site_cache_dir: /var/tmp/dvc/repo/8e5a699173beb5035173f8252c5bcbec

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 23 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Just encountered this issue; downgrading from platformdirs-3.11.0 to platformdirs-3.10.0 fixed it for me 👍

Got the same error today

> dvc pull
ERROR: unexpected error - [Errno 13] Permission denied: '/var/cache/dvc'
> pip list | grep dvc
dvc                          3.49.0

Since platformdirs==3.11.1 no longer exists on pypi https://pypi.org/project/platformdirs/#history , downgrade platformdirs to 3.10.0 works for me

pip install platformdirs==3.10.0

@VK-T So does pip check show any problems with it? Make sure you run in the same env that dvc is installed in.

We require platformdirs<4,>=3.1.1 per https://github.com/iterative/dvc/blob/dad464285e3f107c9e4ccc6e0b82672578037afb/pyproject.toml#L54

I’ve tried to delete the /var/tm/dvc and list dvc files again and everythings seems to be working as expected. 👍

Same issue.

hey @anunayasri ,let’s close it then and wait for someone to share the exact environment where we can reproduce it.

@VK-T Check pip check, you likely have a newer platformdirs installed that we don’t support yet.