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

[Bug] dbt init _always_ launches an interactive prompt when it finds a dbt project directory #7594

Closed
2 tasks done
dbeatty10 opened this issue May 10, 2023 · 0 comments · Fixed by #7609
Closed
2 tasks done
Assignees
Labels
bug Something isn't working init Issues related to initializing the dbt starter project

Comments

@dbeatty10
Copy link
Contributor

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

If the current working directory (or any parent directory) has a dbt_project.yml file, then the -s or --skip-profile-setup parameter is not respected for dbt init my_project

Expected Behavior

No interactive prompt for dbt init when the either -s or --skip-profile-setup parameter.

Steps To Reproduce

Start with an empty folder with dbt 1.5.0 installed.

Create a minimal dbt_project.yml in the current working directory (it must have a profile: key):

name: my_project

config-version: 2
version: 1.0.0
profile: test

Run the following:

dbt init my_project --skip-profile-setup --profiles-dir .

Observe that it launches an interactive prompt:

Setting up your profile.
Which database would you like to use?

Delete the dbt_project.yml file.

Re-run a similar command as before:

dbt init my_project2 --skip-profile-setup --profiles-dir .

Observe that it does not launch an interactive prompt.

Relevant log output

N/A

Environment

- OS:
- Python:
- dbt: 1.5.0

Which database adapter are you using with dbt?

postgres

Additional Context

We can see that self.ask_for_adapter_choice() is guarded by if not self.args.skip_profile_setup here:

if not self.args.skip_profile_setup:
if not self.check_if_can_write_profile(profile_name=project_name):
return
adapter = self.ask_for_adapter_choice()

But it is not guarded here:

adapter = self.ask_for_adapter_choice()

This can be solved a couple ways:

  • Add an if statement to guard the relevant code
  • Do a more involved refactoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working init Issues related to initializing the dbt starter project
Projects
None yet
1 participant