Skip to content

stage add: fails with dirs that will be created later by the cmd(s) #5802

@jorgeorpinel

Description

@jorgeorpinel

Bug Report

Description

If the stage being defined creates a dir and files in this dir are stage outputs, stage add will fail (because it can't write the corresponding .gitignore file).

Reproduce

$ dvc stage add -n hidir -o dir/hi 'mkdir dir && echo hi > dir/hi'
ERROR: unexpected error - [Errno 2] No such file or directory: '/.../dir/.gitignore'

Expected

I guess the full path to the .gitignore in question should be created if needed. Or maybe create it at repro? Not sure how, but I would expect the stage definition not to fail for this.

Environment information

Output of dvc doctor:

$ dvc doctor
DVC version: 2.0.17 (pip)
---------------------------------
Platform: Python 3.6.9 on Linux-5.4.72-microsoft-standard-WSL2-x86_64-with-Ubuntu-18.04-bionic
Supports: gdrive, hdfs, http, https, s3, ssh, oss
Cache types: <https://error.dvc.org/no-dvc-cache>
Caches: local
Remotes: None
Workspace directory: ext4 on /dev/sdb
Repo: dvc, git

Metadata

Metadata

Assignees

No one assigned

    Labels

    A: pipelinesRelated to the pipelines featurep2-mediumMedium priority, should be done, but less important

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions