Does localisation commute with Hom for finitely-generated modules?

Question. Let $R$ be a ring, $\mathfrak{p}$ a prime, $M$ a finitely-generated $R$-module, and $N$ any $R$-module. Is the natural map $$\textrm{Hom}_R(M, N)_\mathfrak{p} \to \textrm{Hom}_{R_\mathfrak{p}}(M_\mathfrak{p}, N_\mathfrak{p})$$ an isomorphism (of $R_\mathfrak{p}$-modules)?

I can prove this in the case when $M$ is finitely presented: indeed, let $S$ be any flat $R$-algebra, and let $$R^m \to R^n \to M \to 0$$ be a right-exact sequence; tensoring with $S$ gives another right-exact sequence $$S^m \to S^n \to M \mathbin{\otimes_R} S \to 0$$ and applying hom functors, we get left-exact sequences $$0 \to \textrm{Hom}_R(M, N) \to N^n \to N^m$$ $$0 \to \textrm{Hom}_S(M \mathbin{\otimes_R} S, N \mathbin{\otimes_R} S) \to (N \mathbin{\otimes_R} S)^n \to (N \mathbin{\otimes_R} S)^m$$ and $S$ is flat, so tensoring the first sequence yields $$0 \to \textrm{Hom}_R(M, N) \mathbin{\otimes_R} S \to (N \mathbin{\otimes_R} S)^n \to (N \mathbin{\otimes_R} S)^m$$ but extending the sequences by $0$ to the left, and putting in vertical maps between the last two, we conclude that $\textrm{Hom}_R(M, N) \mathbin{\otimes_R} S \cong \textrm{Hom}_S(M \mathbin{\otimes_R} S, N \mathbin{\otimes_R} S)$ by the five lemma (modulo checking commutativity of diagrams). This is essentially the proof Eisenbud gives [Commutative Algebra, Prop. 2.10].

The trouble with extending it to a proof for finitely-generated modules is that we have to replace $R^m$ with a potentially arbitrary submodule $K$ of $R^n$, and that may not be free or even finitely-generated without some additional assumptions on $R$. I can't see an abstract nonsense proof of the claim, but I admit I haven't tried a bare-hands proof. However, is the claim even true?


Let me try a counterexample. I will take $N=R$. Consider $\phi : R^2\to R$ the linear map $(x,y)\mapsto x+y$, $\rho : R\to R_P$ the localization map at some prime ideal $P$, $K=\phi^{-1}(\ker(\rho))$ and $M=R^2/K$. Then, as in the first part of your question, one can see that $$\mathrm{Hom}(M, R)_P\to \mathrm{Hom}(M_P, R_P)$$ is surjective if and only if $$ \mathrm{Hom}(K, R)_P\to \mathrm{Hom}(K_P, R_P)$$ is injective when restricted to the image of $\mathrm{Hom}(R^2, R)_P\to \mathrm{Hom}(K, R)_P$. Let $\psi=\phi|_K$. Then the image of $\psi_P$ in $\mathrm{Hom}(K_P, R_P)$ is zero by the construction of $K$. Now let us see under which condition $\psi_P=0$. This is equivalent to $\exists s\in R\setminus P$ such that $s\psi=0$. Or $s\mathrm{Im}(\psi)=0$. As $\phi$ is surjective, $\mathrm{Im}(\psi)=\ker\rho$. So $$ \psi_P=0 \Longleftrightarrow \exists s\in R\setminus P, \ s\ker\rho=0.$$ So to have a counterexample, it is enough to find $R, P$ such that the kernel of $R\to R_P$ is not killed by any $s\notin P$.

Consider $R$ the product of infinitely many copies of $\mathbb F_2$ (say indexed by $\mathbb N$). All prime ideals are maximal and correspond to ultrafilters (see http://en.wikipedia.org/wiki/Ultrafilter) of $\mathbb N$. Some of them are obivous: those with $0$ in a fixed component. They correspond to principal ultrafilters. Let $P$ be a maximal ideal corresponding to a non-principal ultrafilter (it is known that such ultrafilters exist). The kernel of $R\to R_P=\mathbb F_2$ is $P$. If $P$ was killed by a single $s\notin P$, $s=(a_0, a_1,....)$, then $P$ is killed by some $t=(0,...,a_r,0,..)$ with $a_r\ne 0$. So $P\subseteq \mathrm{Ann}(t)$. But the latter is a maximal ideal corresponding to a principal ultrafilter. Contradiction.