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

Cannot depend on a git package if the git package depends on a path package. #2447

Closed
xuanswe opened this issue Apr 12, 2020 · 20 comments
Closed

Comments

@xuanswe
Copy link

xuanswe commented Apr 12, 2020

I have a problem when I want to add dependency from another team.

Assume my company has a partner. The partner allows my company access to their git repository ssh://git@partner.com/root_project.git. In root_project, we have 2 sub-projects: project_a and project_b. Below is the pubspec.yaml of project_a:

# /project_a/pubspec.yaml

dependencies:
  project_b:
    path: ../project_b

My pubspec.yaml:

dependencies:
  project_a:
    git:
      url: ssh://git@partner.com/root_project.git
      path: project_a

If I run pub get, I hope that it's smart enough to find project_b from relative path of the git repository.

Unfortunately, I get error: dependency: "../project_b" is a relative path, but this isn't a local pubspec.

The problem is that I have no permission to change the file /project_a/pubspec.yaml to use git url because it's not my project.

@sigurdm
Copy link
Contributor

sigurdm commented Apr 17, 2020

Yes, my guess is that these are the same.

Is the path being interpreted relative to the git root?
Ie. what happens if you use:

# /project_a/pubspec.yaml

dependencies:
  project_b:
    path: project_b

@xuanswe
Copy link
Author

xuanswe commented Apr 17, 2020

Edit: to be clear, I rename project names in the example.

Is the path being interpreted relative to the git root?

  • The partner project has 2 sub projects (partner_project_a depends on partner_project_b). Both are belong to the partner.
  • partner_project_a point to partner_project_b using local relative path.
  • The configuration of local path is correct and relative to the repository root.

Ie. what happens if you use:

# /project_a/pubspec.yaml

dependencies:
  project_b:
    path: project_b

As I mentioned, partner_project_a is not my project so I cannot change /partner_project_a/pubspec.yaml.

My project depends on partner_project_a:

# my_project/pubspec.yaml
dependencies:
  partner_project_a:
    git:
      url: ssh://git@partner.com/partner_root_project.git
      path: partner_project_a

@sigurdm
Copy link
Contributor

sigurdm commented Apr 20, 2020

It was not meant as a solution, just to explore what is currently happening when you have a path dependency in a git dependency.

@sigurdm
Copy link
Contributor

sigurdm commented Apr 20, 2020

Nevermind - I realize now that pub doesn't support relative paths from git at all.

@jonasfj
Copy link
Member

jonasfj commented Apr 20, 2020

You can work around this with dependency_overrides (this is not ideal). You can also make a local clone of root_project and use path-dependencies in your project. I would suggest avoid use of path-dependencies in root_project, such that it can be depended on directly from a pubspec.yaml.

Another option for sharing private dependencies is to use a private pub repository.


I think the fix for pub is #449, and that we can close this as a duplicate. I don't think this is a priority for us right now, if someone wants to work on and has an idea for how to solve it feel free to ping me on the original issue.

@jonasfj jonasfj closed this as completed Apr 20, 2020
@jonasfj jonasfj added the closed-duplicate Closed in favor of an existing report label Apr 20, 2020
@xuanswe
Copy link
Author

xuanswe commented Apr 20, 2020

You can work around this with dependency_overrides (this is not ideal)

Thanks for suggestion! Currently I checkout project locally as workaround. But dependency_overrides seems to be easier.

@xuanswe
Copy link
Author

xuanswe commented Apr 20, 2020

You can work around this with dependency_overrides (this is not ideal)

Tested but unfortunately it doesn't help.

@zmtzawqlp
Copy link

any update? dependency_overrides is not work at my side.

@sigurdm
Copy link
Contributor

sigurdm commented Apr 28, 2020

I don't think we'll prioritize work on this issue in the short-term future.

Your best bet might be to make a local check-out and use a path-dependency to that.

@jonasfj
Copy link
Member

jonasfj commented Mar 9, 2021

Reading more carefully, I'm not sure this is a dup of #449

@kmod-midori
Copy link

kmod-midori commented Apr 1, 2021

dependencies:
  audio_service:
    git:
      url: https://github.com/ryanheise/audio_service.git
      ref: one-isolate
      path: audio_service

dependency_overrides:
  audio_service_platform_interface:
    git:
      url: https://github.com/ryanheise/audio_service.git
      ref: one-isolate
      path: audio_service_platform_interface

Doing this still does not work:

Error on line 13, column 11: Invalid description in the "audio_service" pubspec on the "audio_service_platform_interface" dependency: "../audio_service_platform_interface" is a relative path, but this isn't a local pubspec.
   ╷                                                                    
13 │     path: ../audio_service_platform_interface                      
   │           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                      
   ╵  

It seems that the error is raised even before dependency_overrides are evaluated.

@spydon
Copy link

spydon commented Nov 23, 2021

That dependency_overrides doesn't work in this specific case makes it very hard to work with non-published versions of packages on monorepos that use path dependencies, like the structure we have in Flame. This should be labeled as a bug imho.

@spydon
Copy link

spydon commented Nov 23, 2021

Dived into the code a bit, the problem is that the description is parsed and checked before the dependencyOverrides are checked here.
I don't know much about pub, but maybe that check could just be skipped if _dependencyOverrides contains the currently checked package name?

@Cloudef
Copy link

Cloudef commented Feb 8, 2022

I'm currently using path to workaround flutter/flutter#63240 but this behavior certainly isn't helpful as now the dependency can't be used from git.

@sadi304
Copy link

sadi304 commented Oct 31, 2022

Anyone found any work around for this case?

@ankit1kmr
Copy link

any update on this other than cloning the dependency locally and giving the path ?

stevehayles added a commit to stevehayles/flutter-maplibre-gl that referenced this issue Dec 19, 2022
Path dependency override don't appear to work for dependencies in flutter.  Seems to be a known bug (see dart-lang/pub#2447)
stevehayles added a commit to stevehayles/flutter-maplibre-gl that referenced this issue Dec 19, 2022
Path dependency override don't appear to work for dependencies in flutter.  Seems to be a known bug (see dart-lang/pub#2447)
@sigurdm
Copy link
Contributor

sigurdm commented Jan 13, 2023

Closing this as duplicate of #449

@sigurdm sigurdm closed this as not planned Won't fix, can't repro, duplicate, stale Jan 13, 2023
@MohammedSalehelShazly
Copy link

see this solution it may help you.

@RubenGarcia
Copy link

RubenGarcia commented Dec 5, 2024

I am also affected.
dart --version
Dart SDK version: 3.3.3 (stable) (Tue Mar 26 14:21:33 2024 +0000) on "macos_arm64"

@sigurdm
Copy link
Contributor

sigurdm commented Dec 5, 2024

@RubenGarcia this should be fixed in dart 3.4 and onwards: https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md#pub-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests