Issue when removing defined metrics from a .yml file (dbt Metrics)

(dbt core 1.4.6)

The problem I am having has to do with dbt Metrics. I have been using dbt Metrics for most of 2023 and in general it works well for me, however, when I try to remove derived metrics I tend to encounter an error message like this one:

Compilation Error
  Metric 'metric.redshift.out_of_stock_percent' (models/metrics/definitions/met_whs_inventory_processing.yml) depends on a source named 'out_of_stock_sku_count' which was not found

It seems that dbt is still trying to calculate the ‘out_of_stock_percent’ metric. However, I have removed this metric from the .yml file, and I have removed all upstream and downstream references to the metric from every model in the warehouse. It seems obvious from the error message that I am (somewhere in my scripts) asking dbt to calculate this metric using fields which are not there, but really, I’ve checked and triple checked and I am not sure why it’s trying to calculate this metric any longer as it isn’t anywhere to be found in my scripts. I deleted every reference because I no longer need the metric, and just want to keep the models clean.

This only seems to be a problem with derived metrics (e.g. using one metric as a numerator, and a second metric as a denominator, in order to calculate a third derived metric.) Removing/renaming non-derived metrics causes no problems.

Additionally, this error message only occurs when I am trying to run dbt-build on my local git branch. When I push the branch to my company’s remote git server, everything runs without any errors… so it seems like somehow the prompt to build the metric has been cached, and I need to clear the cache, but I’m not exactly a dbt/git expert so I’m not sure what I can try.

I first encountered the error maybe 5 months ago and still havemn’t figured out how to fix it despite combing documentation, StackOverflow, etc. I am reaching out here out of sheer desperation :sweat_smile:

Please let me know if I can provide any more information to help resolve this. Thank you.

delete compile folder works for me

Thanks for the suggestion, however I tried deleting the compiled folder (found within target in the file tree) but it doesn’t seem to change anything for me