When a vector field can be scaled to form a conservative vector field

Consider a vector field given by its components $g_i(x_1, \dots, x_n)$. It is well known that necessary and sufficient condition for a following system $$ \frac{\partial f}{\partial x_i} = g_i(x_1, \dots, x_n) $$ to have a solution is circulation of $\vec g$ being zero around any closed path: $$ \oint \vec g\, d\vec r = 0. $$ I wonder if a given non-conservative field $\vec g$ could be scaled some way so the new field will be conservative. In other words there exists $\mu(x_1, \dots x_n) \neq 0$ such the following system has a solution $$ \frac{\partial f}{\partial x_i} = \mu(x_1,\dots,x_n) g_i(x_1, \dots, x_n). $$ The scalar field $\mu$ acts like a kind of an integrating factor. For $n = 2$ such $\mu$ always exists, but for higher $n$ it does not seem to do.

For $n=2$ the $\mu$ may be obtained by solving the equation $$ 0 = \begin{vmatrix} \partial_x & \partial _y\\ \mu g_x & \mu g_y \end{vmatrix} = \mu \left(\frac{\partial g_y}{\partial x} - \frac{\partial g_x}{\partial y}\right) + g_y \frac{\partial \mu}{\partial x} - g_x \frac{\partial \mu}{\partial y}. $$ Then $\operatorname{rot} \mu \vec g = \vec 0$.

For $n > 2$ this approach (zerowing the rotor) leads to a system of PDE's which is almost never consistent.


There's a very good answer to an equivalent question here.

Take the example of 3D, where I'll restate things avoiding the language of differential forms. The existence of $\mu$ is locally equivalent to $\nabla\times \vec{g}$ being orthogonal to $\vec{g}$ (at least if we relax the requirement that $\mu$ must be nonzero everywhere). To show that this condition is necessary, suppose we have found $f$ and $\mu$ such that $\nabla f=\mu\vec{g}$, and take the curl: $$ 0=\nabla\times\nabla f=\nabla\times(\mu \vec{g})=\mu \nabla\times\vec{g}+(\nabla\mu) \times\vec{g}\\ \implies \vec{g}\cdot\nabla\times\vec{g}=\mu^{-1}\vec{g}\cdot(\vec{g}\times\nabla\mu)=0 $$

A simple counterexample is $\vec{g}=(y,0,1)$, so $\nabla\times\vec{g}=(0,0,-1)$, and these are not perpendicular. There's no $\mu$ such that $\mu\vec{g}$ is conservative, even locally.