This question is inspired by an exercise in Hartshorne's Algebraic Geometry. I am just stuck on one small step. The question is as follows (I will use the language of algebraic geometry, but the question is really just one of commutative algebra):
Let $X$ be a noetherian scheme and let $\mathcal{F}$ be a coherent sheaf. Suppose the stalk $\mathcal{F}_{p}$ of $\mathcal{F}$ at some point $p$ is a free $\mathcal{O}_{X,p}$-module. Show that there is a neighbourhood $U$ of $p$ such that $\mathcal{F}|_{U}$ is free.
I feel like I am very close. My attempt so far is to choose an affine open neighbourhood $V = \text{Spec }A$ (with $A$ noetherian) of $p$ with the point $p$ corresponding to a prime ideal $\mathfrak{p}$ of $A$. We can choose a finitely-generated $A$-module $M$ so that $\mathcal{F}|_{V} = \widetilde{M}$. Now in the language of commutative algebra, we have an exact sequence $$ 0 \longrightarrow I \longrightarrow A^{\oplus n} \longrightarrow M \longrightarrow 0. $$ Localizing at $\mathfrak{p}$ gives us the exact sequence $$ 0 \longrightarrow I_{\mathfrak{p}} \longrightarrow A_{\mathfrak{p}}^{\oplus n} \longrightarrow M_{\mathfrak{p}} \longrightarrow 0, $$ and by assumption we know that $M_{\mathfrak{p}}$ is a free $A_{\mathfrak{p}}$-module. To complete the question, all I need to do is show that $I$ vanishes in the localization at $\mathfrak{p}$, and then since $I$ is finitely generated I can find an $s \not \in \mathfrak{p}$ that annihilates $I$, and thus conclude that the coherent sheaf is free on the distinguished open affine $D(s)$. The problem is, I can't seem to be able to show that $I_{\mathfrak{p}}$ actually does vanish.
My first approach was to use the fact that $M_{\mathfrak{p}}$ is free, and hence the second sequence splits, making $I_{\mathfrak{p}}$ a direct summand of a free module, and hence projective. Then since a projective module over a local ring is free, I would have that $I_{\mathfrak{p}}$ is free. But that still didn't allow me to conclude that it was $0$.
My second approach was to think about what it means for $I_{\mathfrak{p}}$ to (not) be $0$. To not be $0$ would mean that there is some $i \in I$ which is not annihilated by any $s \not \in \mathfrak{p}$, and then attempted to make a torsion argument which seemed to go nowhere.
Is there a way to conclude this easily? I am starting to wonder if it is actually true, but it does seem to be.
I don't think this approach is going to work: If for example $M_{\mathfrak{p}}$ is a free $A_{\mathfrak{p}}$-module of rank $m$ and $n>m$, then $I_{\mathfrak{p}}$ does not vanish.
Here is what you could do instead: Given a map $\varphi\colon A_{\mathfrak{p}}^n\to M_{\mathfrak{p}}$ of $A_{\mathfrak{p}}$-modules you can certainly lift this to a map $\varphi_f\colon A_f^n \to M_f$ of $A_f$-modules (just write the image of $e_i=(0,\ldots,0,1,0,\ldots,0)$ in $M_{\mathfrak{p}}$ with a common denominator $f$).
Show that, if $\varphi$ is an isomorphism, then you can in fact adjust/ choose $f$ in such a way that $\varphi_f$ is an isomorphism. $(\textit{Hint}$: Consider the kernel of $\varphi_f$ and observe that it vanishes once localized at $\mathfrak{p}$ and similarly for the cokernel).