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-3382] [Bug] dbt deps --add-package does not work #9076

Closed
2 tasks done
seub opened this issue Nov 14, 2023 · 5 comments
Closed
2 tasks done

[CT-3382] [Bug] dbt deps --add-package does not work #9076

seub opened this issue Nov 14, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@seub
Copy link
Contributor

seub commented Nov 14, 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

The dbt deps --add-package command does not work. Unless I'm missing something, it's not doing anything.

Also, note that the doc doesn't give the correct syntax:

  • add --package instead of --add-package
  • an incorrect --add flag is mentioned

Expected Behavior

Adds entry to packages.yml

Steps To Reproduce

dbt deps --add-package dbt-labs/dbt_utils --version 1.0.0

Relevant log output

No response

Environment

- OS: Ubuntu 16.04
- Python: 3.9.16
- dbt: 1.7.1

Which database adapter are you using with dbt?

No response

Additional Context

No response

@seub seub added bug Something isn't working triage labels Nov 14, 2023
@github-actions github-actions bot changed the title [Bug] dbt deps --add-package does not work [CT-3382] [Bug] dbt deps --add-package does not work Nov 14, 2023
@dbeatty10 dbeatty10 self-assigned this Nov 15, 2023
@dbeatty10
Copy link
Contributor

Thanks for reporting this @seub !

I opened a PR to fix the documentation here: dbt-labs/docs.getdbt.com#4470

Could you try out these examples and see if they work for you?

# add package from hub (--source arg defaults to "hub")
dbt deps --add-package dbt-labs/dbt_utils@1.0.0

# add package from hub with semantic version range
dbt deps --add-package dbt-labs/snowplow@">=0.7.0,<0.8.0"

# add package from git
dbt deps --add-package https://github.com/fivetran/dbt_amplitude@v0.3.0 --source git

# add package from local
dbt deps --add-package /opt/dbt/redshift --source local

# add package to packages.yml and package-lock.yml WITHOUT actually installing dependencies
dbt deps --add-package dbt-labs/dbt_utils@1.0.0 --dry-run

@seub
Copy link
Contributor Author

seub commented Nov 15, 2023

Thanks @dbeatty10.

I tried these examples and they all result in a similar error:

dbt deps --add-package dbt-labs/dbt_utils@1.0.0

03:02:33  Running with dbt=1.7.1
03:02:34  Encountered an error:
argument of type 'bool' is not iterable
03:02:34  Traceback (most recent call last):
  File "/path/to/project/.venv/lib/python3.9/site-packages/dbt/cli/requires.py", line 90, in wrapper
    result, success = func(*args, **kwargs)
  File "/path/to/project/.venv/lib/python3.9/site-packages/dbt/cli/requires.py", line 75, in wrapper
    return func(*args, **kwargs)
  File "/path/to/project/.venv/lib/python3.9/site-packages/dbt/cli/requires.py", line 151, in wrapper
    return func(*args, **kwargs)
  File "/path/to/project/.venv/lib/python3.9/site-packages/dbt/cli/requires.py", line 197, in wrapper
    return func(*args, **kwargs)
  File "/path/to/project/.venv/lib/python3.9/site-packages/dbt/cli/main.py", line 492, in deps
    results = task.run()
  File "/path/to/project/.venv/lib/python3.9/site-packages/dbt/task/deps.py", line 207, in run
    self.add()
  File "/path/to/project/.venv/lib/python3.9/site-packages/dbt/task/deps.py", line 160, in add
    packages_yml = self.check_for_duplicate_packages(packages_yml)
  File "/path/to/project/.venv/lib/python3.9/site-packages/dbt/task/deps.py", line 138, in check_for_duplicate_packages
    if self.args.add_package["name"] in val:
TypeError: argument of type 'bool' is not iterable

I used Python 3.9.16, dbt-core 1.7.1, dbt-snowflake 1.7.0.

@dbeatty10
Copy link
Contributor

Oof.

What are the contents of packages.yml? If it exists, what are the contents of package-lock.yml?

If you start with no packages.yml at all and run that command, do you still get that same error?

@seub
Copy link
Contributor Author

seub commented Nov 15, 2023

Ah, I see, it doesn't like warn-unpinned: false.

If I start with this packages.yml:

packages:
  - git: https://github.com/fivetran/dbt_amplitude

then everything works fine, however I get the error with this:

packages:
 - git: https://github.com/fivetran/dbt_amplitude
   warn-unpinned: false

Looking at the code in dbt-core, it seems to me that the in on line 138 should be replaced by an ==.

(Better yet, first find the correct value for val, i.e. the one where the key is package/git/local/tarball. Isn't there a method for that somewhere?)

dbeatty10 added a commit to dbt-labs/docs.getdbt.com that referenced this issue Nov 15, 2023
[Preview](https://docs-getdbt-com-git-dbeatty-fix-dbt-deps-add-package-dbt-labs.vercel.app/reference/commands/deps)

## What are you changing in this pull request and why?

Fixing the code examples per
dbt-labs/dbt-core#9076 by using test examples
from dbt-labs/dbt-core#8408

## Checklist
- [x] Review the [Content style
guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md)
and [About
versioning](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#adding-a-new-version)
so my content adheres to these guidelines.
- [x] I've checked that the code examples work
- [x] I've confirmed that the preview renders correctly
@dbeatty10
Copy link
Contributor

Thanks again for reporting this and helping get to the bottom of this @seub !

I just opened #9104, and I'm going to close this one in favor of it and dbt-labs/docs.getdbt.com#4470.

@dbeatty10 dbeatty10 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 16, 2023
@dbeatty10 dbeatty10 removed the triage label Nov 16, 2023
@dbeatty10 dbeatty10 removed their assignment Nov 16, 2023
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

2 participants