Fix file asset access issues on CRAN - DEM.tif excluded from package build#136
Fix file asset access issues on CRAN - DEM.tif excluded from package build#136
Conversation
- Add skip_if checks in test-wbt_source.R to handle missing sample data - Improve sample_dem_data() to use tempdir() when package dir is read-only Co-authored-by: brownag <20842828+brownag@users.noreply.github.com>
The pattern ^.*\.tif$ was excluding ALL .tif files including the required sample data file inst/extdata/DEM.tif. Changed to ^[^/]*\.tif$ to only exclude .tif files in the package root directory. Co-authored-by: brownag <20842828+brownag@users.noreply.github.com>
|
This is a reasonable solution. I didn't see this PR, was expecting a comment in the issue (I dont know why). Kicking the tires on possibly using the Copilot features more. I am pleased to see we arrived at similar, but non-identical solutions. I want to only include inst/extdata/DEM.tif, nothing more. So #137 with the explicit negative lookahead in .Rbuildignore will supersede this. We also both defensively added skips to the tests for possible missing files, which is good. I don't think If you have any additional comments, make them in review of #137. I think we can safely ignore the other missing file output from the check logs... that is functioning as intended, but a bit verbose on linux |
Problem
CRAN check failures were occurring with the error
Error: File () does not existintest-wbt_source.R. The issue statement suggested this was related to recent changes insample_dem_data()behavior and the read-only filesystem on CRAN check servers.Root Cause
The actual root cause was in
.Rbuildignore: the pattern^.*\.tif$was excluding all.tiffiles from the package build, including the essential sample data fileinst/extdata/DEM.tif. This caused the file to be completely missing from the package tarball distributed to CRAN, resulting insample_dem_data()returning an empty string and subsequent test failures.Changes Made
1. Fixed
.Rbuildignorepattern (Critical)Changed:
^.*\.tif$→^[^/]*\.tif$The original pattern matched any path ending in
.tif, includinginst/extdata/DEM.tif. The new pattern only matches.tiffiles in the package root directory, ensuring that sample data files ininst/extdata/are properly included in package builds.2. Added defensive test guards
Added
skip_if(f == "")checks intests/testthat/test-wbt_source.Rafter calls tosample_dem_data()andsample_soils_data(). This makes tests gracefully skip when sample data is unavailable, consistent with the pattern already used in all other test files in the package.3. Enhanced
sample_dem_data()robustnessImproved the function to handle read-only filesystem scenarios (common on CRAN check servers):
file.access()tempdir()when the package directory is read-onlyTesting
These changes ensure that:
Fixes the CRAN check errors reported by Kurt Hornik on the Debian check systems.
Original prompt
This section details on the original issue you should resolve
<issue_title>bug: file asset access issues on CRAN</issue_title>
<issue_description>Need to resolve the following errors and warnings on the check server. Possibly related to recent changes in behavior of
sample_dem_data(), which I thought would be safe to do. If not that need to assess where this regression came from. Kurt Hornik states "check problems on the Debian systems may be caused by attempts to write to the user library to which all packages get installed beforechecking (and which now is remounted read-only for checking)."
The WBT tool calls should fail gracefully in absence of the WBT binary. There might need to be some tests skipped but also the internal file handling should be reviewed to make sure we are conforming with CRAN guidelines regarding the tools user directory folder. I think the issue is actually with the missing Geotiff data file, not the WBT binary, despite the sh stdout in the check log.