r-lib / pak

A fresh approach to package installation
https://pak.r-lib.org
648 stars 57 forks source link

Can't install package from tarball #659

Open grst opened 1 week ago

grst commented 1 week ago

I am having issues installing a library from a tarball. Installing the same library from the source folder works without issues. Installing the same tarball with R CMD INSTALL also works without issues.

Repex

Rscript -e "usethis::create_package('mypkg')"
Rscript -e "pak::pkg_install('./mypkg')"
# ...
# ✔ Installed mypkg 0.0.0.9000 (local) (74ms)
# ✔ 1 pkg: added 1, dld 1 (NA B) [6.4s]
tar cvf mypkg.tar.gz mypkg
R CMD INSTALL mypkg.tar.gz
# ...
# ** testing if installed package keeps a record of temporary installation path
# * DONE (mypkg)
Rscript -e "pak::pkg_install('./mypkg.tar.gz')"
WARNING: ignoring environment value of R_HOME
Error: 
! error in pak subprocess
Caused by error: 
! Could not solve package dependencies:
* local::./mypkg.tar.gz: ! pkgdepends resolution error for local::./mypkg.tar.gz.
Caused by error: 
! Line starting 'mypkg/ ...' is malformed!
---
Backtrace:
1. pak::pkg_install("./mypkg.tar.gz")
2. pak:::remote(function(...) get("pkg_install_make_plan", asNamespace("pak"))(...), …
3. err$throw(res$error)
---
Subprocess backtrace:
1. base::withCallingHandlers(cli_message = function(msg) { …
2. get("pkg_install_make_plan", asNamespace("pak"))(...)
3. prop$stop_for_solution_error()
4. private$plan$stop_for_solve_error()
5. pkgdepends:::pkgplan_stop_for_solve_error(self, private)
6. base::throw(new_error("Could not solve package dependencies:\n", msg, …
7. | base::signalCondition(cond)
8. global (function (e) …
Execution halted

Sitrep

> pak::pak_sitrep()
* pak version:
- 0.7.2
* Version information:
- pak platform: x86_64-conda-linux-gnu (current: x86_64-conda-linux-gnu, compatible)
- pak repository: - (local install?)
* Optional packages installed:
- pillar
* Library path:
- /dev/shm/sturmgre/conda/envs/test_r/lib/R/library
* pak is installed at /dev/shm/sturmgre/conda/envs/test_r/lib/R/library/pak.
* Dependency versions:
- callr      3.7.5 
- cli        3.6.2 
- curl       5.2.1 
- desc       1.4.3 
- filelock   1.0.3 
- jsonlite   1.8.8 
- lpSolve    5.6.20
- pkgbuild   1.4.4 
- pkgcache   2.2.1 
- pkgdepends 0.7.2 
- pkgsearch  3.1.3 
- processx   3.8.4 
- ps         1.7.6 
- R6         2.5.1 
- zip        2.3.1 
* Dependencies can be loaded
R version 4.3.3 (2024-02-29)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Rocky Linux 9.3 (Blue Onyx)
gaborcsardi commented 1 week ago

Does it work if you build a proper R package with R CMD build?

grst commented 1 week ago

That works! Now is this a bug of a feature? ;)

gaborcsardi commented 1 week ago

You cannot create an R package with tar.cf, if that's your intention, you need to call R CMD build.

grst commented 1 week ago

Well, but it works with R CMD INSTALL and remotes. In any case, this could benefit from a clearer error message :)