ropensci / rix

Reproducible development environments for R with Nix
https://docs.ropensci.org/rix/
GNU General Public License v3.0
136 stars 12 forks source link

Error in pulling URL: GitHub repo #156

Closed artur-sannikov closed 5 months ago

artur-sannikov commented 5 months ago

Hi,

I tried to test the rix() function beyond the examples provided in vignette.

Here is an example, that should pull rix, dplyr, and oma packages.

library(rix)

rix(r_ver = "latest",
    r_pkgs = c("dplyr", "ggplot2"),
    git_pkgs = list(list(package_name = "rix",
                   repo_url = "https://github.com/b-rodrigues/rix",
                   branch_name = "master",
                   commit = "76d1bdd03d78589d399b4b9d473ecde616920a82"),
                   list(package_name = "dplyr",
                   repo_url = "https://github.com/tidyverse/dplyr",
                   branch_name = "main",
                   commit = "d69802224a1df16d7a795ce313880116ea62ed6e"),
                   list(package_name = "oma",
                   repo_url = "https://github.com/microbiome/OMA",
                   branch_name = "master",
                   commit = "cb796e4d0862ab423ea9f19fb34ee26b93900e51")
    ),
    ide = "other",
    project_path = ".",
    overwrite = TRUE)

The commits are

  1. dplyr: commit
  2. oma: commit

I get this error for both packages:

Error in get_sri_hash_deps(repo_url, branch_name, commit) : 
  Error in pulling URL: https://github.com/microbiome/OMA. 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.
Calls: rix ... fetchgits -> paste -> lapply -> FUN -> get_sri_hash_deps
Execution halted

same for dplyr.

However, adding these packages manually to default.nix results in successful build.

let
 pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/2b80ce7707aedcb79be09e412b6dd6c15c578ab2.tar.gz") {};
 rpkgs = builtins.attrValues {
  inherit (pkgs.rPackages) dplyr ggplot2;
};
 git_archive_pkgs = [(pkgs.rPackages.buildRPackage {
    name = "rix";
    src = pkgs.fetchgit {
      url = "https://github.com/b-rodrigues/rix";
      branchName = "master";
      rev = "5c506fa6dadc0c680756abebde5c32f6b65e6218";
      sha256 = "sha256-tankAsiZ8BdC6GdtKO/vnc/JpwOUTomSm9z7AoZD5+U=";
    };
    propagatedBuildInputs = builtins.attrValues {
      inherit (pkgs.rPackages) codetools httr jsonlite sys;
    };
  })

  (pkgs.rPackages.buildRPackage {
    name = "oma";
    src = pkgs.fetchgit {
      url = "https://github.com/microbiome/OMA";
      branchName = "master";
      rev = "cb796e4d0862ab423ea9f19fb34ee26b93900e51";
      sha256 = "sha256-1SWWwKX4YsfTcCSQGYpYc9XFOu2OlndflIUMCwy/St8=";
    };
    propagatedBuildInputs = builtins.attrValues {
      inherit (pkgs.rPackages) mia;
    };
  })

  (pkgs.rPackages.buildRPackage {
    name = "dplyr";
    src = pkgs.fetchgit {
      url = "https://github.com/tidyverse/dplyr";
      branchName = "main";
      rev = "d69802224a1df16d7a795ce313880116ea62ed6e";
      sha256 = "sha256-4OjdiaCTo03IOmFD6CJviEhwuvoY+LgvU7/R4LxHU6o=";
    };
    propagatedBuildInputs = builtins.attrValues {
      inherit (pkgs.rPackages) cli generics glue lifecycle magrittr pillar R6 rlang tibble tidyselect vctrs;
    };
  })  ];
  system_packages = builtins.attrValues {
  inherit (pkgs) R glibcLocales nix ;
};
  in
  pkgs.mkShell {
    LOCALE_ARCHIVE = if pkgs.system == "x86_64-linux" then  "${pkgs.glibcLocales}/lib/locale/locale-archive" else "";
    LANG = "en_US.UTF-8";
    LC_ALL = "en_US.UTF-8";
    LC_TIME = "en_US.UTF-8";
    LC_MONETARY = "en_US.UTF-8";
    LC_PAPER = "en_US.UTF-8";
    LC_MEASUREMENT = "en_US.UTF-8";

    buildInputs = [ git_archive_pkgs rpkgs  system_packages  ];

  }
b-rodrigues commented 5 months ago

Looks like digital ocean is down

image

the virtual server is hosted there

artur-sannikov commented 5 months ago

I can ping your server git2nixsha.dev though. And there are no problems with rix and fusen packages.

b-rodrigues commented 5 months ago

Could you try again? Restarted the server

artur-sannikov commented 5 months ago

No, still the same error. This is my default.nix

let
 pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/2b80ce7707aedcb79be09e412b6dd6c15c578ab2.tar.gz") {};
 rpkgs = builtins.attrValues {
  inherit (pkgs.rPackages) dplyr ggplot2;
};
 git_archive_pkgs = [(pkgs.rPackages.buildRPackage {
    name = "rix";
    src = pkgs.fetchgit {
      url = "https://github.com/b-rodrigues/rix";
      branchName = "master";
      rev = "5c506fa6dadc0c680756abebde5c32f6b65e6218";
      sha256 = "sha256-tankAsiZ8BdC6GdtKO/vnc/JpwOUTomSm9z7AoZD5+U=";
    };
    propagatedBuildInputs = builtins.attrValues {
      inherit (pkgs.rPackages) codetools httr jsonlite sys;
    };
  })
 ];
  system_packages = builtins.attrValues {
  inherit (pkgs) R glibcLocales nix ;
};
  in
  pkgs.mkShell {
    LOCALE_ARCHIVE = if pkgs.system == "x86_64-linux" then  "${pkgs.glibcLocales}/lib/locale/locale-archive" else "";
    LANG = "en_US.UTF-8";
    LC_ALL = "en_US.UTF-8";
    LC_TIME = "en_US.UTF-8";
    LC_MONETARY = "en_US.UTF-8";
    LC_PAPER = "en_US.UTF-8";
    LC_MEASUREMENT = "en_US.UTF-8";

    buildInputs = [ git_archive_pkgs rpkgs  system_packages  ];      
  }

Next,

nix-shell
Rscript build_env.R

build_env.R:

library(rix)

rix(r_ver = "latest",
    r_pkgs = c("dplyr", "ggplot2"),
    git_pkgs = list(list(package_name = "rix",
                   repo_url = "https://github.com/b-rodrigues/rix",
                   branch_name = "master",
                   commit = "76d1bdd03d78589d399b4b9d473ecde616920a82"),
                   list(package_name = "dplyr",
                   repo_url = "https://github.com/tidyverse/dplyr",
                   branch_name = "main",
                   commit = "d69802224a1df16d7a795ce313880116ea62ed6e"),
                   list(package_name = "oma",
                   repo_url = "https://github.com/microbiome/OMA",
                   branch_name = "master",
                   commit = "cb796e4d0862ab423ea9f19fb34ee26b93900e51")
    ),
    ide = "other",
    project_path = ".",
    overwrite = TRUE)

Error

Error in get_sri_hash_deps(repo_url, branch_name, commit) : 
  Error in pulling URL: https://github.com/microbiome/OMA. 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.
Calls: rix ... fetchgits -> paste -> lapply -> FUN -> get_sri_hash_deps
Execution halted
b-rodrigues commented 5 months ago

It seems to be related to one of OMA’s dependencies, {miatime}, itself also on github. You likely need to follow the following vignette https://b-rodrigues.github.io/rix/articles/z-advanced-topic-handling-packages-with-remote-dependencies.html

EDIT: But on second thought, the expression should be generated anyways, but would not build. I’ll have to check out what’s wrong. Could you try with another commit?

b-rodrigues commented 5 months ago

I wonder if it could be an issue with the package structure, that doesn’t seem to be proper. The NAMESPACE file is empty, there is no man/ folder, etc. I wonder if this could be the source of the issue?

artur-sannikov commented 5 months ago

I tried with miaTime.

This outputs nix code

library(rix)

rix(r_ver = "latest",
    r_pkgs = NULL,
    system_pkgs = NULL,
    git_pkgs =  list(package_name = "oma",
                   repo_url = "https://github.com/microbiome/OMA",
                   branch_name = "master",
                   commit = "cb796e4d0862ab423ea9f19fb34ee26b93900e51"),
    ide = "other",
    project_path = ".",
    overwrite = FALSE,
    print = TRUE)                  

I then tried with dplyr's commit 1.1.4 and yes, this code worked fine:

library(rix)

rix(r_ver = "latest",
    r_pkgs = NULL,
    system_pkgs = NULL,
    git_pkgs =  list(package_name = "dplyr",
                   repo_url = "https://github.com/tidyverse/dplyr",
                   branch_name = "main",
                   commit = "74de24448833278fc03c8ba5f455aa7c888295b8"),
    ide = "other",
    project_path = ".",
    overwrite = FALSE,
    print = TRUE)    

Let me try oma with another commit.

artur-sannikov commented 5 months ago

I tried with two other commits: b07181d484f39ab1f3df2d493dcc304edc956e32 and latest deployed on GitHub pages 917cf7f55dbb3113e504babb9aa7c3d5a0c89fe1.

You are right, it might be the issue with the package structure.

b-rodrigues commented 5 months ago

I tried with two other commits: b07181d484f39ab1f3df2d493dcc304edc956e32 and latest deployed on GitHub pages 917cf7f55dbb3113e504babb9aa7c3d5a0c89fe1.

You are right, it might be the issue with the package structure.

so both these commits worked? That’s quite interesting, I must remember to document this! if the issue is solved, would you kindly close this thread?

artur-sannikov commented 5 months ago

No, these commits fail with rix. If I add them manually to default.nix, then everything is fine.

b-rodrigues commented 5 months ago

ok, let’s keep this open then. I’ll have to take a closer look

artur-sannikov commented 5 months ago

I noticed that I haven't written the rix code to generate default.nix for miaTime.

library(rix)

rix(r_ver = "latest",
    r_pkgs = NULL,
    system_pkgs = NULL,
    git_pkgs =  list(package_name = "miaTime",
                   repo_url = "https://github.com/microbiome/miaTime",
                   branch_name = "master",
                   commit = "9fe9771f7329fc991796eb79cc1e17ee06e1bc24"),
    ide = "other",
    project_path = ".",
    overwrite = FALSE,
    print = TRUE)       
artur-sannikov commented 5 months ago

I just tested with miaTime, mia, and dplyr. It now generates a default.nix file without issues. Probably was a temporary hiccup.

b-rodrigues commented 5 months ago

thanks for checking again, it’s weird though, I wonder what happened.

artur-sannikov commented 5 months ago

Anyway, OMA still has the same issue but I guess it's not rix problem.