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

Subset issues when using piggyback and renv #70

Closed
PMassicotte opened this issue May 18, 2022 · 8 comments
Closed

Subset issues when using piggyback and renv #70

PMassicotte opened this issue May 18, 2022 · 8 comments

Comments

@PMassicotte
Copy link
Contributor

PMassicotte commented May 18, 2022

I have found multiple issues when using piggyback with renv enabled project that are likely linked to how subset works for tibble vs data.frame.

For example, the function pb_releases() do not work when renv is enabled. This is occurring here:

addr <- remotes[remotes[["name"]] == remote, "url"][["url"]]

With renv enabled, remotes[remotes[["name"]] == remote, "url"] is a character. Hence, using [["url"]] does not work. When renv is not enabled, the same is a tibble and can be subsetted using [["url"]].

I have made an animated GIF that hopefully show the problem clearly. You can see that pb_releases() stops working when renv is activated. When renv is deactivated, pb_releases() works again.

Peek 2022-05-18 13-40

Note that the same problem occurs for some other functions of the packages.

@tanho63
Copy link
Collaborator

tanho63 commented May 18, 2022

the problem is specifically guess_repo() right? not pb_releases()?

@PMassicotte
Copy link
Contributor Author

PMassicotte commented May 18, 2022

Well, as I understand, pb_releases() calls guess_repo(), but yes is it occurring specifically in guess_repo().

@tanho63
Copy link
Collaborator

tanho63 commented May 18, 2022

Interesting! Can you try using gh::gh_tree_remote() as the argument to repo? Might be an easy drop-in fix

@PMassicotte
Copy link
Contributor Author

I have tried this but no luck:

> pb_releases(repo = gh::gh_tree_remote())
Error in strsplit(repo, "/") : non-character argument

@tanho63
Copy link
Collaborator

tanho63 commented May 18, 2022

Oh. Duh, it returns a list. But at least it returns something! I suspect the problem is that renv only caches the import dependencies so when guess_repo tries to use gert it fails somehow.

@PMassicotte
Copy link
Contributor Author

If I install tibble in the project (which is afterwards cached by renv) it works. So it looks like that

remotes <- gert::git_remote_list(repo)

returns a tibble. Since it was not needed in my project, it simply returns a dataframe.

Then, subsetting a data.frame here:

remotes[remotes[["name"]] == remote, "url"][["url"]]

does not work since remotes[remotes[["name"]] == remote, "url"] returns a character rather than a tibble if tibble is loaded.

@tanho63
Copy link
Collaborator

tanho63 commented May 18, 2022

Oh so it just needs to be remotes$url[remotes$name == remote] then…

I wonder if that’s better or worse than shortening dependencies and using gh here for that too

@PMassicotte
Copy link
Contributor Author

Oh so it just needs to be remotes$url[remotes$name == remote]] then…

Exactly!

I wonder if that’s better or worse than shortening dependencies and using gh here for that too

Good question :)

cboettig added a commit that referenced this issue May 19, 2022
Data frame subsetting works if tibble is not installed (closes #70).
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