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

Git dependencies don't work with relative PUB_CACHE #4493

Closed
FireLizard opened this issue Jan 15, 2025 · 3 comments
Closed

Git dependencies don't work with relative PUB_CACHE #4493

FireLizard opened this issue Jan 15, 2025 · 3 comments
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@FireLizard
Copy link

Environment

Dart Version: 3.6.1
OS: Ubuntu 22.04 LTS

Problem

When setting PUB_CACHE to a relative path like .pub-cache then dart pub get -v (output below) can not get information about a package included as git-repository defined in pubspec.yaml. Only if PUB_CACHE is an absolute path (e.g. $HOME/.pub-cache) it is working. With Dart Version 3.3.4 there was no issue.

Maybe we should document this circumstance.

pubspec.yaml

name: my_project
publish_to: 'none'
environment:
  sdk: ">=3.4.0 <4.0.0"
dependencies:
  some-package:
    git: https://github.com/vendor/repo.git

The git-repo does not have any tag. I don't define ref, therefore HEAD is used.

output

IO  : Spawning "git --git-dir=.pub-cache/git/cache/some-package-da7b21c760c51da18bebb4859505a5f86964ac9c show 512149311978d182854b46364d327cd0328a0834:pubspec.yaml" in /home/user/my_project/.pub-cache/git/cache/some-package-da7b21c760c51da18bebb4859505a5f86964ac9c
IO  : Finished git. Exit code 128.
    | Nothing output on stdout.
    | stderr:
    | | fatal: not a git repository: '.pub-cache/git/cache/some-package-da7b21c760c51da18bebb4859505a5f86964ac9c'
    | |

Resources

@sigurdm sigurdm changed the title Document PUB_CACHE should always be an absolute path Git dependencies don't work with relative PUB_CACHE Jan 16, 2025
@sigurdm
Copy link
Contributor

sigurdm commented Jan 16, 2025

Thanks for reporting

Rather than documenting this problem we should fix it!

The problem is when we run git, we don't run it from the current directory, but from the package directory itself, so the relative path is broken.

workingDir: path,

Either we should make the path absolute, or we run it from the current dir.

@sigurdm sigurdm added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Jan 16, 2025
@sigurdm
Copy link
Contributor

sigurdm commented Jan 20, 2025

This is fixed in #4494

@sigurdm sigurdm closed this as completed Jan 20, 2025
@FireLizard
Copy link
Author

Great 😀 Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants