Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-3416] [Bug] dbt clean --project-dir always raises DbtRuntimeError, even when files are within project directory #9138

Open
2 tasks done
jaklan opened this issue Nov 23, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@jaklan
Copy link

jaklan commented Nov 23, 2023

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

dbt clean --project-dir raises a RuntimeError when using a relative path:

Runtime Error
  dbt will not clean the following directories outside the project: ['<root-path>/common/dbt/target']

Expected Behavior

No error.

Steps To Reproduce

  1. Create a dbt project in e.g. <root-path>/common/dbt directory
  2. Run cd <root-path> && dbt clean --project-dir common/dbt
  3. Command fails with the error:
    Runtime Error
      dbt will not clean the following directories outside the project: ['<root-path>/common/dbt/target']
    
    although the target directory is obviously inside the project

Relevant log output

No response

Environment

- OS: macOS
- Python: 3.10.9
- dbt: 1.7.2

Which database adapter are you using with dbt?

redshift

Additional Context

No response

@jaklan jaklan added bug Something isn't working triage labels Nov 23, 2023
@github-actions github-actions bot changed the title [Bug] dbt clean --project-dir fails when using a relative path [CT-3416] [Bug] dbt clean --project-dir fails when using a relative path Nov 23, 2023
@jtcohen6
Copy link
Contributor

Hey @jaklan, thanks for opening! It sounds like this may be an issue with the logic introduced in #8469, to detect whether dbt clean is being asked to delete files outside the active project directory. I can reproduce this in the simple way you suggested:

  1. Go to a dbt project
  2. cd ..
  3. dbt clean --project-dir <projectname>
  4. See the error:
Runtime Error
  dbt will not clean the following directories outside the project: ['/.../<projectname>/target']

In the meantime, you can work around this (and achieve the previous "unsafe" behavior) by passing an additional flag, as suggested in #9089 (comment):

dbt clean --no-clean-project-files-only

@jtcohen6 jtcohen6 removed the triage label Nov 27, 2023
@jtcohen6 jtcohen6 changed the title [CT-3416] [Bug] dbt clean --project-dir fails when using a relative path [CT-3416] [Bug] dbt clean --project-dir always raises DbtRuntimeError, even when files are within project directory Nov 27, 2023
@jaklan
Copy link
Author

jaklan commented Nov 27, 2023

@jtcohen6 thanks for the reply! I haven't noticed this new flag - pretty useful, not only as a workaround for this issue 😄

@mustafa0taru
Copy link

@jtcohen6 thanks for pointing out the workaround. Super helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants