Map Algebra expression in a model fails on open workspace

I have model which runs 2 processes that create rasters and a third process that (attempts to) add the two of them using Map Algebra. The expression is very simple, just "%Raster_A%" + "%Raster_B%".

This third process aborts with ERROR 000539: Error running expression: rcexec() <type 'exceptions.RuntimeError'>: ERROR 010167: Could not open workspace .

The help file for Error 000539 : Error message from Python does not appear relevant, this isn't a problem with python syntax or type use. There is no help page for #010167, but the "not open workspace" is self explanatory.

I haven't found any info on rcexec() but name and context suggest it's a method for shelling out to an external python process and getting something back. It's reasonable to assume the external process doesn't know it's being executed from a model and that the workspace lock it's encountering is from the parent, and that this is okay. Or, maybe rcexec is not encountering a lock and what's really having trouble with is finding the workspace. I have no way of knowing (I don't think).

The model has an Output Workspace input parameter, which the two antecedent processes use just fine. I tried connecting the Output Workspace input parameter to the map algebra expression as Enviroment > Workspace > Current Workspace to no effect.

Any ideas how to track the source of this error down and fix it?

update: Aha! The environment is not clean. I edited the model and deleted the Current and Scratch workspace settings, and they reverted to the default C:\Users\matt\ArcGIS\default.gdb. At that point the error changed from can't open to invalid workspace:

ERROR 000539: Error running expression: rcexec() <type 'exceptions.RuntimeError'>:
ERROR 000875: Output raster: T:\env298.gdb\A_plus_B's workspace is an invalid output workspace.


The curious thing is that the workspace specified in the error was the model's workspace at one time. So rcexec() is not respecting the value set in the model's environment properties, nor the process's workspace environment property.

Now I just need to figure out how to really reset the environment to defaults.

-
Have you been able to perform any other actions in that workspace, like creating/deleting featureclasses, editing records, etc? – Get Spatial Jun 12 '12 at 0:29
@GetSpatial, yes. The other processes in the model run just fine, both those that precede the failure and the one that follows (when I step through the model manually). I can also load one of the layers in a map and do things like calculate field without trouble. I've also tried running the model from standalone ArcCatalog instead of ArcMap to see if it was a problem with "this layer is being looked at in a map and is therefore locked"; no change. – matt wilkie Jun 12 '12 at 16:11

Somewhere along the line the Map Algebra output raster field was set to a hard coded path instead of the desired %Output Workspace%\out_raster_name. Change that and it's all good.