Potential issues with the path Info&Sols
I have a test that don't pass on the server and I don't know exactly why:
Error (test-query_soil_textures.R:20:1): (code run outside of `test_that()`)
Error: [rast] file does not exist: data/soil_textures/Info&Sols/soil_textures_infosols.tif
Backtrace:
▆
1. └─RADIS.api::query_soil_textures(...) at test-query_soil_textures.R:20:1
2. ├─terra::rast(path_db) at RADIS.api-dev/R/query_soil_textures.R:34:3
3. └─terra::rast(path_db)
4. └─terra (local) .local(x, ...)
5. └─terra:::messages(r, "rast")
6. └─terra:::error(f, x@pntr$getError())
I suppose it's an issue related to the & present in the path:
Yes, the & character can definitely be a problem in file paths! The & character has special meaning in many contexts:
Issues with & in File Paths:
1. Shell/Command Line Issues
-
&is used to run commands in the background in bash/shell - Can cause path parsing issues in system calls
2. URL Encoding Issues
-
&is a special character in URLs (parameter separator) - May get encoded/decoded incorrectly
3. R/File System Issues
- Some R functions may not handle
&properly - Windows vs Linux path handling differences
Solutions:
Option 1: Escape the Path
# Escape the & character
file_path <- "data/soil_textures/Info\\&Sols/soil_textures_infosols.tif"
Option 2: Use file.path() for Better Path Handling
file_path <- file.path("data", "soil_textures", "Info&Sols", "soil_textures_infosols.tif")
Option 3: Quote the Path
file_path <- shQuote("data/soil_textures/Info&Sols/soil_textures_infosols.tif")
Option 4: Rename the Directory (Recommended)
The cleanest solution is to rename the directory to avoid special characters:
Ran terminal command: ls -la /workspaces/RADIS.api-dev/data/soil_textures/