r-lib / pak

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

`pak::pak("MLopez-Ibanez/irace")` does not record RemoteSha or equivalent unlike `devtools::install_github("MLopez-Ibanez/irace")` #669

Closed MLopez-Ibanez closed 2 months ago

MLopez-Ibanez commented 2 months ago

devtools::install_github("MLopez-Ibanez/irace") records the remote revision SHA in DESCRIPTION as RemoteSha, which is very useful to track the actual github version of the files people are using.

Unfortunately, pak::pak("MLopez-Ibanez/irace") does not seem to record similar information, which makes very difficult to track which version of the package somebody downloaded.

gaborcsardi commented 2 months ago

That's not what I see:

❯ pak::pak("MLopez-Ibanez/irace")
✔ Loading metadata database ... done

→ Will install 2 packages.
→ All 2 packages (1.77 MB) are cached.
+ irace        3.9.0.9000 👷‍♂️🔧 (GitHub: 51c44b3)
+ spacefillr   0.3.3
ℹ No downloads are needed, 2 pkgs (1.77 MB) are cached
✔ Got spacefillr 0.3.3 (aarch64-apple-darwin20) (1.77 MB)
✔ Got irace 3.9.0.9000 (source) (18.25 MB)
✔ Installed spacefillr 0.3.3  (34ms)
ℹ Packaging irace 3.9.0.9000
✔ Packaged irace 3.9.0.9000 (6.3s)
ℹ Building irace 3.9.0.9000
✔ Built irace 3.9.0.9000 (3.4s)
✔ Installed irace 3.9.0.9000 (github::MLopez-Ibanez/irace@51c44b3) (39ms)
✔ 1 pkg + 7 deps: kept 4, added 2, dld 2 (NA B) [17s]
❯ packageDescription("irace")
Package: irace
Type: Package
...
Built: R 4.4.1; aarch64-apple-darwin20; 2024-08-01 15:37:27 UTC; unix
RemoteType: github
RemoteHost: api.github.com
RemoteRepo: irace
RemoteUsername: MLopez-Ibanez
RemotePkgRef: MLopez-Ibanez/irace
RemoteRef: HEAD
RemoteSha: 51c44b3d88c5b3fba076551559c0b1d5b3dadbf3
GithubRepo: irace
GithubUsername: MLopez-Ibanez
GithubRef: HEAD
GithubSHA1: 51c44b3d88c5b3fba076551559c0b1d5b3dadbf3
MLopez-Ibanez commented 2 months ago

I did a bit more debugging. It seems devtools creates the RemoteSha before building but pak does it before installing, so the package itself does not have access to it. I am using this to debug it: https://github.com/MLopez-Ibanez/irace/blob/master/R/aaa.R

And this is what it prints when using pak:

/tmp/RtmpAL14MT/Rbuild172b14d5e75ac/irace : 1 
/tmp/RtmpAL14MT/Rbuild172b14d5e75ac/irace : RemoteSha= unknown 
/tmp/RtmpAL14MT/Rbuild172b14d5e75ac/irace : git= /usr/bin/git 
/tmp/Rtmp49Uzq1/R.INSTALL173617e249ef3/irace : 1 
/tmp/Rtmp49Uzq1/R.INSTALL173617e249ef3/irace : RemoteSha= unknown 
/tmp/Rtmp49Uzq1/R.INSTALL173617e249ef3/irace : git= /usr/bin/git 

and this is what it prints when installing with devtools:

/tmp/RtmporFRvW/Rbuild175994fb66f16/irace : 1 
/tmp/RtmporFRvW/Rbuild175994fb66f16/irace : RemoteSha= 85ecaf0333378db3b031bd3552e0d2648cec10de 
/tmp/RtmporFRvW/Rbuild175994fb66f16/irace : git= /usr/bin/git 
/tmp/RtmporFRvW/Rbuild175994fb66f16/irace : realversion= 3.9.0.9000.85ecaf0333378db3b031bd3552e0d2648cec10de 
/tmp/RtmpAxP9Ri/R.INSTALL1762833db9b1f/irace : 1 
/tmp/RtmpAxP9Ri/R.INSTALL1762833db9b1f/irace : RemoteSha= 85ecaf0333378db3b031bd3552e0d2648cec10de 
/tmp/RtmpAxP9Ri/R.INSTALL1762833db9b1f/irace : git= /usr/bin/git 
/tmp/RtmpAxP9Ri/R.INSTALL1762833db9b1f/irace : realversion= 3.9.0.9000.85ecaf0333378db3b031bd3552e0d2648cec10de 
MLopez-Ibanez commented 2 months ago

It works! Many thanks! :smile: