TITLE: Why doesn't Hom commute with taking stalks?
QUESTION [27 upvotes]: I have been learning about sheaves and am thinking about the following problem. Let $F$ and $G$ be sheaves, say of abelian groups, on a space $X$. The sheaf $Hom(F, G)$ is defined by $Hom(F, G)(U)=Mor(F|_U, G|_U)$.  Given a point $p \in X$ and an open set $U$ containing $p$, a morphism $\varphi: F|_U \rightarrow G|_U$ induces a homomorphism on stalks $\phi: F_p \rightarrow G_p$, which is an element of $Hom(F_p, G_p)$.  Thus, by the universal property of direct limits, we have a homomorphism from $Hom(F, G)_p$ to $Hom(F_p, G_p)$.  However, this is not in general injective or surjective.  Why not? An example or a hint leading towards an example would be much appreciated.  I have thought about this for some simple sheaves (such as skyscraper sheaves), but it seems to be true in those cases.
I am also interested in a more general answer if there is one, i.e. something category theoretic about Hom and direct limits.

REPLY [2 votes]: Here is a somewhat abstract explanation giving a "deeper reason" for why Hom doesn't commute with taking stalks. In categorical logic, it is well known that in general, only so-called geometric constructions commute with taking inverse image under geometric morphisms. Calculating the stalk at a point is an example of such a process of taking an inverse image.
Anton's answer shows that the Hom construction is not geometric in general.
But there is a very general situation in which $\mathcal{H}om(F, \cdot)$ is geometric. Namely, it suffices for $F$ to be an $\mathcal{O}_X$-module on a ringed space $X$ which is of finite presentation around $x \in X$, i.e. such that there is a short exact sequence
$$ \mathcal{O}_X^n \longrightarrow \mathcal{O}_X^m \longrightarrow F \longrightarrow 0 $$
on an open neighbourhood of $x$. (You can use the constant sheaf $\underline{\mathbb{Z}}$ as the structure sheaf $\mathcal{O}_X$ if you want to stay in the setting of sheaves of abelian groups.) This is because in this case, $\mathcal{H}om(F, G)$ is canonically isomorphic to
$$\left\{ x \in G^m \,\middle|\, \sum_i a_{ij} x_i = 0 \in G, j = 1,\ldots,n \right\},$$
where $A = (a_{ij}) \in \mathcal{O}_X^{m \times n}$ is the presentation matrix and $G$ is an arbitrary $\mathcal{O}_X$-module, and this construction is patently geometric.