Consider this partial answer.
The main point is as follows. Consider this question on an arbitrary open set $U\subset \mathbb{R}^n$. Locally (that is to say on $\mathbb{R}^n$, as every small ball $B_r(x)\subset U$ is diffeomorphic to $\mathbb{R}^n$),we can find a potential (more generally, work with differential forms to avoid use of scalar products etc.) if the so called "local conservativity" equations are satisfied : $\partial_i F_j=\partial_j F_i$ for all $i,j=1,...,n$. This means that locally (for example, when $U$ is simply connected), this property becomes global - every vector field on a simply connected open set has a potential. However, there might arise problems to obtain a global result (like a global potential field) without any global information for $U$ (such as simple connectedness).
As an example, consider $X=\mathbb R^2\setminus \{0\}, f(x,y)=\frac {(-y,x)}{x^2+y^2}$, as in the cited answer.
Let $U=\mathbb R^2\setminus (-\infty,0]$ and $\theta:U\to (-\pi,\pi)$ be the angle from the positive real ray with values in $(-\pi,\pi)$. since $\frac{y}{x}=\tan \theta$
$$ \frac{dy}{x}-\frac{y\,dx}{x^2}=\frac{d\theta}{cos^2\theta}=\frac{x^2+y^2}{x^2}d\theta \implies d\theta =\frac{-y\,dx+x\,dy}{x^2+y^2}$$
This exactly means that $\theta$ is a potential for $f$ on $U$.
Similarly, consider $V=\mathbb R^2\setminus [0,\infty)$ and $\phi:V\to (0,2\pi)$ be the angle from the positive ray with values in $(0,2\pi)$. again, since $\frac{y}{x}=tan\phi$, we again see that $\phi$ is a potential for $f$ on $V$.
Therefore, we found potentials locally, as $U$ and $V$ are open subsets of $\mathbb R^2\setminus \{0\}$. The problem is that these potentials do not patch up to a global potential on $\mathbb R^2\setminus \{0\}$, as they disagree on (expected, i.e. via continuation) values on the real line. In fact, no two such local potentials will ever patch up to a global potential.
Now taking a path $:c:[0,2\pi]\to \mathbb R^2\setminus \{0\}$ to be $c(t)=(\cos t,\sin t)$ we can calculate the path integral of the vector field over $c$:
$$c'(t)=(-\sin t,\cos t), \quad f(c(t))=(-\sin t,\cos t)/(\cos ^2 t+\sin^2 t)=(-\sin t,\cos t)$$
so
$$\oint_c f\cdot d\textbf{r}=\int_0^{2\pi} (-\sin t,\cos t)\cdot (-\sin t,\cos t)dt=\int_0^{2\pi}\sin^2 t+\cos^2 tdt=\int_0^{2\pi}dt=2\pi. $$
This implies that if we take two paths from $p=(-1,0)$ to $q=(1,0)$, each of which goes from another side of $(0,0)$, then the result will differ by $2\pi$, which means that this integral is dependent on the path taken.