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-528] [Bug] Local package relative paths in packages.yml are converted to absolute rather than relative symlinks #4538

Closed
1 task done
mbhynes opened this issue Dec 30, 2021 · 6 comments
Labels
bug Something isn't working deps dbt's package manager jira security stale Issues that have gone stale

Comments

@mbhynes
Copy link

mbhynes commented Dec 30, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Problem

  • dbt allows local packages to be specified in the packages.yml, such as:
packages:
  - local: ../common
  • These kind of relative package paths are a convenient and straightforward way of managing dependencies in a large organization with project structures such as the following, in which some local projects are "common" or shared macros across a company, e.g. in a common project:
org_monorepo/
- org_monorepo/dbt/
  - org_monorepo/dbt/project1/
  - org_monorepo/dbt/project2/
  - org_monorepo/dbt/common

image

  • This is unexpected and undesirable behaviour, especially when the relative tree structure is desired in source code management & deployment; e.g. the devs will write on their local machines, but CI/CD and deployment occurs on other machines in which the absolute path of the symlink doesn't exist.

Expected Behavior

If a relative path is given, then the symlink should be this relative path.

After all--- user has specified relative for a reason, and could provide an absolute path themselves if that was the desired behaviour.

Steps To Reproduce

Please see the example above; any relative path provided in a packages.yml gets converted to an absolute symlink, when it should be converted to a relative symlink

Relevant log output

No response

Environment

- OS: Mac 11.6
- Python: (multiple), but Python 3.9
- dbt:

installed version: 0.20.0
Plugins:
  - bigquery: 0.20.0


### What database are you using dbt with?

_No response_

### Additional Context

_No response_
@mbhynes mbhynes added bug Something isn't working triage labels Dec 30, 2021
@mbhynes mbhynes changed the title [Bug] Local package relative paths in packages.yml are converted to *absolute* paths [Bug] Local package relative paths in packages.yml are converted to absolute rather than relative symlinks Dec 31, 2021
@gshank
Copy link
Contributor

gshank commented Jan 10, 2022

Thanks for reporting this. I can see that it would be much more convenient for your use case to have relative symlinks. The relevant code is in core/dbt/deps/local.py, LocalPinnedPackage.install. It seems like we could check for the existence of the absolute path, but symlink the relative path.

I'm not sure if there would be operating system complications with this though. Windows can sometimes be an issue. We'll look into this.

@gshank gshank removed the triage label Jan 17, 2022
@jtcohen6 jtcohen6 added the packages Functionality for interacting with installed packages label Jan 17, 2022
@jtcohen6 jtcohen6 added deps dbt's package manager and removed packages Functionality for interacting with installed packages labels Mar 30, 2022
@jtcohen6 jtcohen6 added the jira label Apr 21, 2022
@github-actions github-actions bot changed the title [Bug] Local package relative paths in packages.yml are converted to absolute rather than relative symlinks [CT-528] [Bug] Local package relative paths in packages.yml are converted to absolute rather than relative symlinks Apr 21, 2022
@nathaniel-may
Copy link
Contributor

@gshank, my understanding is that the issue would arise if you run dbt deps on your local machine then copy the dependencies somewhere with a different file structure (like a different machine for deployment) and attempt to run dbt run from there. Is this the only problem this would cause? Is this a method we support for deploying a dbt project?

CC: @jtcohen6

@Raalsky
Copy link
Contributor

Raalsky commented May 15, 2022

Hey, I'm not sure how it's correlated with the above - let me know if I should move to a new issue 😉.

I have following structure:

projects:
  - utils
  - mailing
    - integration_tests

Where utils, mailing and integration_tests are dbt projects. Placing of integration_tests were suggested in dbt docs.

Now mailing project has following package.yml:

packages:
  - local: ../utils

And integration_tests - package.yml:

packages:
  - local: ../

Now running dbt deps inside of integration_tests failures with:

21:04:28  Running with dbt=1.1.0
21:04:29  Encountered an error:
Runtime Error
  no dbt_project.yml found at expected path [...]/projects/mailing/utils/dbt_project.yml

This suggests that integration_tests has following "computed" dependencies:

packages:
  - local: ../
  - local: ../utils

Instead of expected one:

packages:
  - local: ../
  - local: ../../utils

It seems that path resolving for utils was made in respect of absolute path of source project instead of dependencies' project path. I'm not sure how much it's lack of knowledge and misexpectations on my side versus real problem.

EDIT: Temporal solutions is placing integration_tests in the same level of utils and mailing but it's not as expressive as could be.

@leahwicz leahwicz added help_wanted Trickier changes, with a clear starting point, good for previous/experienced contributors security and removed help_wanted Trickier changes, with a clear starting point, good for previous/experienced contributors labels May 31, 2022
@leahwicz
Copy link
Contributor

Notes: we would need to check the security implications of adding this functionality and being sure we implement it with the proper guardrails in place

@github-actions
Copy link
Contributor

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue, or it will be closed in 7 days.

@github-actions github-actions bot added the stale Issues that have gone stale label Nov 28, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2022

Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working deps dbt's package manager jira security stale Issues that have gone stale
Projects
None yet
Development

No branches or pull requests

6 participants