mroutis: > @mroutis I think it would be better to use already provided stage.deps and stage.outs, instead of converting them to abspath yourself.

Indeed, @efiop, let send another commit with that change
diff --git a/dvc/project.py b/dvc/project.py
index 542fb32bc..739b874e6 100644
--- a/dvc/project.py
+++ b/dvc/project.py
@@ -146,7 +146,10 @@ class Project(object):
     def _check_circular_dependency(self, deps, outs):
         from dvc.exceptions import CircularDependencyError
 
-        circular_dependencies = set(deps) & set(outs)
+        circular_dependencies = (
+            set(file.path for file in deps) &
+            set(file.path for file in outs)
+        )
 
         if circular_dependencies:
             raise CircularDependencyError(circular_dependencies.pop())
@@ -298,7 +301,7 @@ class Project(object):
                             overwrite=overwrite)
 
         self._check_output_duplication(stage.outs)
-        self._check_circular_dependency(deps, outs)
+        self._check_circular_dependency(stage.deps, stage.outs)
 
         self._files_to_git_add = []
         with self.state:

run: Check whether file specified by the output already exists
DVC version: `0.19.12`
Installation: `Arch Linux AUR package`

This prevents overwritting the file or causing some unexpected behaviour.

```bash
#!/bin/bash

# Clean and create a repository
rm -rf myrepo
mkdir myrepo
cd myrepo

# Init git and dvc
git init
dvc init
git add -A
git commit -m "Init"

# Creating the dependency
echo "hello" > hello.txt

dvc run \
  --file circular-dependency.dvc \
  --deps hello.txt \
  --outs hello.txt \
  'echo "overwrite" > hello.txt'
```
diff --git a/tests/test_run.py b/tests/test_run.py
index b42c90605..ac1eed326 100644
--- a/tests/test_run.py
+++ b/tests/test_run.py
@@ -102,6 +102,21 @@ class TestRunCircularDependency(TestDvc):
                          outs=[self.FOO],
                          fname='circular-dependency.dvc')
 
+    def test_outs_no_cache(self):
+        with self.assertRaises(CircularDependencyError):
+            self.dvc.run(cmd='',
+                         deps=[self.FOO],
+                         outs_no_cache=[self.FOO],
+                         fname='circular-dependency.dvc')
+
+    def test_non_normalized_paths(self):
+        with self.assertRaises(CircularDependencyError):
+            self.dvc.run(cmd='',
+                         deps=['./foo'],
+                         outs=['foo'],
+                         fname='circular-dependency.dvc')
+
+
 class TestRunBadCwd(TestDvc):
     def test(self):
         with self.assertRaises(StageBadCwdError):

pip install -e .[all]
parse_log_pytest
requirements.txt
pytest>=3.3.1 nose>=1.3.7 mock>=2.0.0 coverage>=4.5.1 codecov>=2.0.15 xmltodict>=0.11.0 awscli>=1.14.18 google-compute-engine Pygments collective.checkdocs pytest
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
altgraph==0.17.4
asciimatics==1.14.0
attrs==22.2.0
awscli==1.24.10
azure-common==1.1.28
azure-nspkg==3.0.2
azure-storage-blob==1.3.0
azure-storage-common==1.3.0
azure-storage-nspkg==3.1.0
bcrypt==4.0.1
boto==2.49.0
boto3==1.7.4
botocore==1.10.84
cachetools==4.2.4
certifi==2021.5.30
cffi==1.15.1
charset-normalizer==2.0.12
codecov==2.1.13
collective.checkdocs==0.2
colorama==0.4.4
configobj==5.0.8
configparser==5.2.0
coverage==6.2
cryptography==40.0.2
decorator==4.4.2
distro==1.9.0
docutils==0.16
-e git+https://github.com/iterative/dvc.git@7ae97009fa79ea613510464cef40aa12854dfbea#egg=dvc
future==1.0.0
gitdb==4.0.9
GitPython==3.1.18
google-api-core==1.32.0
google-auth==1.35.0
google-cloud-core==0.28.1
google-cloud-storage==1.12.0
google-compute-engine==2.8.13
google-crc32c==1.3.0
google-resumable-media==2.3.3
googleapis-common-protos==1.56.3
grandalf==0.6
idna==3.10
importlib-metadata==4.8.3
iniconfig==1.1.1
jmespath==0.10.0
jsonpath-rw==1.4.0
macholib==1.16.3
mock==5.2.0
nanotime==0.5.2
networkx==2.5.1
nose==1.3.7
packaging==21.3
paramiko==3.5.1
pefile==2024.8.26
Pillow==8.4.0
pluggy==1.0.0
ply==3.11
protobuf==3.19.6
py==1.11.0
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycparser==2.21
pydot==1.4.2
pyfiglet==0.8.post1
Pygments==2.14.0
PyInstaller==3.3.1
PyNaCl==1.5.0
pyparsing==3.1.4
pytest==7.0.1
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==5.4.1
requests==2.27.1
rsa==4.7.2
s3transfer==0.1.13
schema==0.7.7
six==1.17.0
smmap==5.0.0
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
wcwidth==0.2.13
xmltodict==0.14.2
zc.lockfile==2.0
zipp==3.6.0

name: dvc
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - altgraph==0.17.4
      - asciimatics==1.14.0
      - attrs==22.2.0
      - awscli==1.24.10
      - azure-common==1.1.28
      - azure-nspkg==3.0.2
      - azure-storage-blob==1.3.0
      - azure-storage-common==1.3.0
      - azure-storage-nspkg==3.1.0
      - bcrypt==4.0.1
      - boto==2.49.0
      - boto3==1.7.4
      - botocore==1.10.84
      - cachetools==4.2.4
      - cffi==1.15.1
      - charset-normalizer==2.0.12
      - codecov==2.1.13
      - collective-checkdocs==0.2
      - colorama==0.4.4
      - configobj==5.0.8
      - configparser==5.2.0
      - coverage==6.2
      - cryptography==40.0.2
      - decorator==4.4.2
      - distro==1.9.0
      - docutils==0.16
      - future==1.0.0
      - gitdb==4.0.9
      - gitpython==3.1.18
      - google-api-core==1.32.0
      - google-auth==1.35.0
      - google-cloud-core==0.28.1
      - google-cloud-storage==1.12.0
      - google-compute-engine==2.8.13
      - google-crc32c==1.3.0
      - google-resumable-media==2.3.3
      - googleapis-common-protos==1.56.3
      - grandalf==0.6
      - idna==3.10
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - jmespath==0.10.0
      - jsonpath-rw==1.4.0
      - macholib==1.16.3
      - mock==5.2.0
      - nanotime==0.5.2
      - networkx==2.5.1
      - nose==1.3.7
      - packaging==21.3
      - paramiko==3.5.1
      - pefile==2024.8.26
      - pillow==8.4.0
      - pluggy==1.0.0
      - ply==3.11
      - protobuf==3.19.6
      - py==1.11.0
      - pyasn1==0.5.1
      - pyasn1-modules==0.3.0
      - pycparser==2.21
      - pydot==1.4.2
      - pyfiglet==0.8.post1
      - pygments==2.14.0
      - pyinstaller==3.3.1
      - pynacl==1.5.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pyyaml==5.4.1
      - requests==2.27.1
      - rsa==4.7.2
      - s3transfer==0.1.13
      - schema==0.7.7
      - six==1.17.0
      - smmap==5.0.0
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - wcwidth==0.2.13
      - xmltodict==0.14.2
      - zc-lockfile==2.0
      - zipp==3.6.0
prefix: /opt/conda/envs/dvc

tests/test_run.py::TestRunCircularDependency::test_non_normalized_paths tests/test_run.py::TestRunCircularDependency::test_outs_no_cache
tests/test_run.py::TestRun::test tests/test_run.py::TestRunEmpty::test tests/test_run.py::TestRunMissingDep::test tests/test_run.py::TestRunBadStageFilename::test tests/test_run.py::TestRunNoExec::test tests/test_run.py::TestRunCircularDependency::test tests/test_run.py::TestRunBadCwd::test tests/test_run.py::TestCmdRun::test_run tests/test_run.py::TestCmdRun::test_run_bad_command
dvc/project.py
dvc/project.py