This is a cross-post.
Let $E$ be a smooth vector bundle over a manifold $M$, where $\text{rank}(E) > 1,\dim M > 1$. Suppose that $E$ is equipped with a metric $g$ and an affine connection $\nabla$, such that $\nabla_X g=\omega (X) g$ for every $X \in \Gamma(TM)$. (Here $\omega$ is a one form).
Must $\omega$ be closed?
Clearly, $\nabla$ is metric-compatible ($\nabla g=0$) iff $\omega=0$. Moreover, $\omega=d\phi$ is exact if and only if $\nabla s=0$ where $s=e^{-\phi}g$, i.e. $\nabla$ is metric w.r.t a positive conformal rescaling of $g$. So, an alternative formulation of the question is the following:
Suppose that $\nabla g=\omega (\cdot) g$ for some $\omega \in \Omega^1(M)$. Must $\nabla$ be metric w.r.t a local conformal rescalings of $g$?
Differentiating $\nabla g=\omega (\cdot) g$, we get $R(X,Y)g=d\omega(X,Y)g$, so if $\nabla$ is flat then $\omega$ is closed.
I required $\text{rank}(E) > 1$, since if the rank is $1$, $\nabla g$ can always be written as $\omega (\cdot) g$ for a suitable $\omega$, so the assumption always holds, but I think that $d\omega=0$ does not always hold. Maybe this can be used to construct a counter example of higher rank by taking a direct sum of line bundles.