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

rix() fails for CRAN packages if latest version is specified. #210

Open
eliocamp opened this issue Jun 24, 2024 · 7 comments
Open

rix() fails for CRAN packages if latest version is specified. #210

eliocamp opened this issue Jun 24, 2024 · 7 comments

Comments

@eliocamp
Copy link
Contributor

I get an error if I try to use the latest version of a CRAN package:

library(rix)
rix(r_ver = "latest",
    r_pkgs = "[email protected]",    # Current version
    ide = "rstudio",
    project_path = ".",
    overwrite = TRUE,
    print = FALSE)
#> Error: Request `curl::curl_fetch_memory(url = 'http://git2nixsha.dev:1506/hash?repo_url=https://cran.r-project.org/src/contrib/Archive/Formula/Formula_1.2-5.tar.gz&branchName=&commit=')` failed:
#>  The requested URL returned error: 500
#> If it's a Github repo, check the url, branch name and commit.
#> Are these correct? If it's an archived CRAN package, check the name
#> of the package and the version number.
rix(r_ver = "latest",
    r_pkgs = "[email protected]",    # Old version works
    ide = "rstudio",
    project_path = ".",
    overwrite = TRUE,
    print = FALSE)


rix(r_ver = "latest",
    r_pkgs = "[email protected]",    # Happens with other packages
    ide = "rstudio",
    project_path = ".",
    overwrite = TRUE,
    print = FALSE)
#> Error: Request `curl::curl_fetch_memory(url = 'http://git2nixsha.dev:1506/hash?repo_url=https://cran.r-project.org/src/contrib/Archive/ggplot2/ggplot2_3.5.1.tar.gz&branchName=&commit=')` failed:
#>  The requested URL returned error: 500
#> If it's a Github repo, check the url, branch name and commit.
#> Are these correct? If it's an archived CRAN package, check the name
#> of the package and the version number.

My intuition is that rix() must be looking into CRAN archives. But those only host old versions so it falls back to treating it like a git repo instead.

@b-rodrigues
Copy link
Contributor

yes indeed, you are correct. We would like people to use the actual packages from nixpkgs, and only provide specifying old versions as a convenience. If you absolutely need bleeding edge packages, you can use r_ver = "frozen_edge". See https://b-rodrigues.github.io/rix/articles/z-bleeding_edge.html for more details

@eliocamp
Copy link
Contributor Author

So is it impossible to specify an old R version and the current version of an R package? (say I want to use R 4.3.1 with Formula 1.2-5, which is the current version but also the one available at the time of 4.3.1)

@b-rodrigues
Copy link
Contributor

Due to how packages are updated in nixpkgs, there's no "easy" way of doing it. You can install it from Github though, or you could override the package definition, but we didn't document how to do it as this requires familiarity with Nix. We are thinking about providing a way to do this in the future though

@eliocamp
Copy link
Contributor Author

Are

rix(r_ver = "4.4.1",
    r_pkgs = "[email protected]",  
    ide = "rstudio",
    project_path = ".",
    overwrite = TRUE,
    print = FALSE)

and

rix(r_ver = "4.4.1",
    r_pkgs = "Formula",
    ide = "rstudio",
    project_path = ".",
    overwrite = TRUE,
    print = FALSE)

equivalent configs? If so, wouldn't it make sense for rix to accept both and create the correct nix config?

@b-rodrigues
Copy link
Contributor

b-rodrigues commented Jun 27, 2024

No, because in the first case, Formula will be pulled from CRAN directly, and in the second case, Formula will be pulled from its definition on nixpkgs.

If we want Nix to handle the dependency resolution for us, we need to use the Nix definitions from Nixpkgs. This is why it can be tricky to "mix-and-match" different versions of R and packages with Nix, but also, this should usually not be much of an issue as running one particular (in general older) version of one package with a newer version of R is rarely needed. For example renv wouldn’t allow it, as initializing a project using renv would only download the most up-to-date packages to initialize the project-specific library.

@eliocamp
Copy link
Contributor Author

But if the installed version is the same, wouldn't it make sense for rix to interpret "pkg@vesion" as "pkg" and pull the package from nix anyway.

@b-rodrigues
Copy link
Contributor

b-rodrigues commented Jun 28, 2024

I’ll have to think about this one, but I think it wouldn’t be that easy to implement. Also, I don’t think I want to encourage people to think about individual package versions too much: the idea is to define an environment at a given "snapshot revision" and then just use it. To have something that works like renv, and also ultimately have an renv2nix, we would need to rethink how rix works quite a bit. It’s on the roadmap, but it’ll require more work that we would like leave for a second or third major CRAN release 😄

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

No branches or pull requests

3 participants