Lets say we have variables $h_1 , h_2 , ... h_n$ that depend on our usual coordinates $x_1 , x_2 .... x_n$ in Euclidian space, and basis vectors $\hat{w_1}, \hat{w_2} ... \hat{w_n}$ such that for the position vector $\vec{X}=\sum_{j=1}^{n}x_j e_j =\sum_{j=1}^{n} h_j |w_j| \hat{w_j}$ (the reason for the $|w_j|$ is just to make the basis elements have unit magnitude, sorry if its a little gross). We take the $\hat{w}$'s to be an orthonormal basis.
Lets say we have a vector field $\vec{V}=\sum_{j=1}^{n} f_j(\vec{X})e_j =\sum_{j=1}^{n}g_j(\vec{X})\hat{w_j}$, we'd compute the divergence as $\nabla \cdot \vec{V} = \sum_{j=1}^{n} \frac{\partial\vec{V} \cdot e_j}{\partial x_j}$. Though we typically use the euclidian components when computing divergence it seems like there shouldn't be a problem with converting this expression to another coordinate system.
To get this in a better form we first look at $\vec{V} \cdot e_k=\sum_{j=1}^{n}g_j(\vec{X})\hat{w_j} \cdot e_k$. From our definitions we also see $\hat{w_j}=\frac{1}{|w_j|} \frac{\partial\vec{X}}{\partial h_j}$ so $\hat{w_j} \cdot e_k=\frac{1}{|w_j|}\frac{\partial\vec{X} \cdot e_k}{\partial h_j}=\frac{1}{|w_j|}\frac{\partial x_i}{\partial h_j}$ so $\vec{V} \cdot e_k=\sum_{j=1}^{n}g_j(\vec{X})\frac{1}{|w_j|}\frac{\partial x_k}{\partial h_j}$ Returning to the divergence, $\nabla \cdot \vec{V} = \sum_{i,j=1}^{n} \frac{\partial g_i(\vec{X}) \frac{1}{|w_i|}\frac{\partial x_j}{\partial h_i}}{\partial x_j}$. With the commutativity of partial derivatives we should have $\frac{\partial}{\partial x_j}\frac{\partial x_j}{\partial h_i}=0$, leaving us with $\sum_{i,j=1}^{n} \frac{\partial g_i(\vec{X}) \frac{1}{|w_i|}}{\partial x_j}\frac{\partial x_j}{\partial h_i}=\sum_{i=1}^{n} \frac{\partial g_i(\vec{X}) \frac{1}{|w_i|}}{\partial h_i}$, clearly not correct. The right answer should look like $\sum_{i=1}^{3} \frac{1}{|w_1||w_2||2_3|} \frac{\partial g_i(\vec{X}) \frac{|w_1||w_2||2_3|}{|w_i|}}{\partial h_i}$ in the case n=3, with the more general case following a similar form. From what I can tell these are not equivalent.I can't figure out what is wrong here--any help would be appreciated.