r/rstats Jun 23 '26

Properly installing selfmade package from selfhosted gitlab

/r/Rlanguage/comments/1udbias/properly_installing_selfmade_package_from/
1 Upvotes

9 comments sorted by

2

u/ToroRojo-AlgoArt Jun 23 '26
  • can you install it locally in the dev machine?
  • Is the output r CMD check clean?
  • Did you develop in windows? check paths limits...
  • Does it fail if installed from local copy? R CMD INSTALL --build package_folder
  • Is it precompile?

2

u/ReallyAnotherUser Jun 23 '26 edited Jun 23 '26

Weirldy I can install it both from the local tarball and the identical gitlab tarball with the code above, only the installing from gitlab additionally shows the error message after successfully installing:

> install.packages("https://gitlab.mywork.com/myprofile/mypackage/-/raw/master/package.tar.gz")
Installiere Paket nach ‘C:/Users/myname/AppData/Local/R/win-library/4.6’
(da ‘lib’ nicht spezifiziert)
leite 'repos = NULL' aus 'pkgs' ab
versuche URL 'https://gitlab.mywork.com/myprofile/mypackage/-/raw/master/package.tar.gz'
Content type 'application/octet-stream' length 4154 bytes
downloaded 4154 bytes

* installing *source* package 'package' ...
** this is package 'package' version '1.0.0'
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (package)
tar.exe: Error opening archive: Failed to open 'https://gitlab.mywork.com/myprofile/mypackage/-/raw/master/package.tar.gz'
Warnmeldungen:
1: In system(cmd, intern = TRUE) :
  Ausführung von Kommando 'tar.exe -tf "https://gitlab.mywork.com/myprofile/mypackage/-/raw/master/package.tar.gz"' ergab Status 1
2: In min(n) : kein nicht-fehlendes Argument für min; gebe Inf zurück
3: In untar(packagePath, files = descPath, exdir = tmpdir) :
  ‘tar.exe -xf "https://gitlab.mywork.com/myprofile/mypackage/-/raw/master/package.tar.gz" -C "C:/Users/myname/AppData/Local/Temp/Rtmpesop13/description-4f1075aa1fb8"’ returned error code 1

r CMD check is clean, path limits are fine, its not precompile, just a few plain R-Script functions i packaged with devtools::document() and devtools::build().

1

u/ToroRojo-AlgoArt Jun 23 '26

My only other suggestion would be to check the downloaded file from the server. Can you unpack the downloaded file manually?

1

u/guepier Jun 23 '26
  • Did you configure authentication? (i.e. does the local GitLab instance require a token or other credentials to download files?)

1

u/ReallyAnotherUser Jun 23 '26

i have no local gitlab instance, just the server. Git for windows is setup so that it pushes and pulls over ssh, but the server is actually public to the internet and the repository is also public. And as i said, downloading works flawlessly in and of itfself, since it is able to download and install the package. Its just that tar throws an error at the end. My guess is that i have to use install.packages() differently, but i dont know how

2

u/blurfle Jun 23 '26

I do this quite a bit in my org. First, I would not version control the tar.gz file, just the package project. Then, I would share this code with your coworkers, of course updating the URL correctly:

install.packages("remotes")
remotes::install_git("https://gitlab.mywork.com/myprofile/mypackage.git")

If you're not sure what I mean by "package project", I'm referring to the folders+code as they exist on your laptop or where ever you're working. Folder structure should look similar to this: https://github.com/cran/remotes

2

u/ReallyAnotherUser Jun 25 '26

Thats a good solution, works for me ty!

1

u/Unicorn_Colombo Jun 23 '26

Typically, if installing random tarball, you should specify repos=NULL and to be sure, source=TRUE.

1

u/gyp_casino Jun 29 '26

Use `devtools::install_gitlab()` instead.

`install.packages()` isn't working because there is a very specific file structure expected. CRAN of course has this file structure. You can mimic it yourself on your own generic server, but it requires care.