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

Automatically normalizePath() for local type of references #378

Open
pawelru opened this issue Aug 27, 2024 · 3 comments
Open

Automatically normalizePath() for local type of references #378

pawelru opened this issue Aug 27, 2024 · 3 comments

Comments

@pawelru
Copy link
Contributor

pawelru commented Aug 27, 2024

Given the following file structure:

my_packages/
├── pkg1
├── pkg2
├── pkg3
└── ...

I usually do:

setwd("my_packages/pkg1")

And then want to do the following:

pak::pak("../pkg2")

But it results in the following error:

Error: 
! error in pak subprocess
Caused by error in `get_remote_types(refs)`:
! Cannot parse package:
../pkg2.
ℹ See `?pkgdepends::pkg_refs()` for supported
  package sources.
Type .Last.error to see the more details.

The solution is to convert the path to be in absolute form via normalizePath(). This is definitely not the end of the world but involves a lot of typing given how short&sweet the pak::pak() command is.

My request is: can it be done automatically (for all local type of reference)?

@gaborcsardi
Copy link
Member

Does

pak::pak("local::../pkg2")

work? The regex that recognizes local paths is intentionally conservative, to avoid ambiguity. E.g. foo/bar could be a local directory or a GH repo.

@pawelru
Copy link
Contributor Author

pawelru commented Aug 27, 2024

Interestingly it does. That would mean that "../foo/bar" is not parsable. So the request would be to enhance regex to identify this as a file path

@gaborcsardi
Copy link
Member

Btw. the ./ prefix is already a special case, so this should work as well:

pak::pak("./../pkg2")

I guess we can special case the ../ and ..\ prefixes as well.

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

2 participants