79663845

Date: 2025-06-12 16:21:08
Score: 8 🚩
Natty: 5
Report link

I’m encountering an issue when using the terra package in R in visual code within a Conda environment. When I run R from the interactive terminal (e.g., directly launching R or using the R extension in VSCode), I get the following error when assigning a CRS to a raster:

GDAL Error

r <- rast(nrows=10, ncols=10, xmin=0, xmax=10, ymin=0, ymax=10, crs="EPSG:4326")
Error: [rast] empty srs
In addition: Warning message:
In new_CppObject_xp(fields$.module, fields$.pointer, ...) :
  GDAL Error 1: PROJ: proj_create_from_database: Cannot find proj.db

However, when I run commands via a bash script or directly in the bash terminal, I dont have problems and I can verify that the proj.db file exists and that the PROJ_LIB environment variable is correctly set.

Here’s what I’ve tried so far:

Despite this, the error persists only when running R interactively or inside VSCode, but not when running commands from bash or shell scripts.

Does anyone know why the interactive environment and bash might behave differently with respect to environment variables and locating proj.db? How can I ensure that R correctly recognizes proj.db in all contexts?

Thanks in advance for any help!

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Blacklisted phrase (0.5): How can I
  • Blacklisted phrase (1): any help
  • RegEx Blacklisted phrase (2): Does anyone know
  • RegEx Blacklisted phrase (3): Thanks in advance
  • RegEx Blacklisted phrase (1): I get the following error
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Claudia Verónica Leal Medina