The hash is generated by the hidden hash()
function in packrat
library, and it serves as a package consistency check.
The algorithm generates an md5sum
that is based on the DESCRIPTION
file included in the package tarball, but there is additional logic involved, see lines #103-#107
in the packrat/R/cache.R
source at Github.
In order to obtain the HASH that packrat
expects to find in the packrat.lock
file a direct call to the hash()
function must be made. This function is not exposed in the compiled package, so the only way to access it is to use the packrat
source.
- Obtain a copy of the source of the
packrat
library from CRAN with the correct version
- Extract it into a folder (in my example it is
packrat-0.5.0
)
- Start an R session
The following lines demonstrate how to generate the hash for the package BH-1.66.0-1
(4cc8883584b955ed01f38f68bc03af6d
):
# md5sum() function is neeeded
library(tools)
# relevant source code files are loaded
source('packrat-0.5.0/R/utils.R') # readDcf() function
source('packrat-0.5.0/R/cache.R') # packrat's hash() function
# execute the hash() function on the DESCRIPTION file in the package
print(hash('/usr/local/lib/R/site-library/BH/DESCRIPTION'))
This should return the correct HASH of 4cc8883584b955ed01f38f68bc03af6d
.
I am not aware of any options in packrat
that would allow you to disable HASH checking. If your goal is to manually modify the packrat.lock
file to alter a package version, it is certainly possible by performing this trick.
This could help overcome some minor dependency issues. However, there are two dangers:
- such a package version change may start a cascade of dependency upgrade requirements
- errors appear in your app because of compatibility issues