I am trying to find a reference that states and proves the following Lemma:
Lemma. Let $(X,\mathcal{O}_X)\xrightarrow{f}(Y,\mathcal{O}_Y)\xrightarrow{g}(Z,\mathcal{O}_Z)$ be morphisms of ringed spaces. Then $R(g\circ f)\cong Rg\circ Rf$.
A proof is given by application of 015M: if $\mathcal{I}$ is an injective $\mathcal{O}_X$-module, then $\mathcal{I}$ is flasque (09SX), so $f_*\mathcal{I}$ is flasque too; thus, $f_*\mathcal{I}$ is acyclic (09SY).
I haven't found the result's statement on the Stacks Project (I have only checked on the Cohomology of Sheaves chapter), and I haven't found it either on Hartshorne's or Vakil's.