TITLE: What is an example of $\mathscr O_{Spec R}(U)\neq S^{-1}R$ for some $S$ consisting of the elements of $R$ not vanishing on $U$?
QUESTION [7 upvotes]: I've been meditating on the very basics of algebraic geometry, and in particular on how exactly $X=\operatorname{Spec} R$ relates to its structure sheaf $\mathscr O_X$.
In these meditations, I've realized that the only $\mathscr O_X(U)$ for open subsets $X\setminus V(I)=U\subset X$ that I've come across have turned out to be $S^{-1}R$ where $S=\{f\in R \ \colon \ V(f)\subset V(I)\}$, i.e. they have always been the localization of $R$ at the set of elements of $R$ which do not vanish on $U$. It is easy to see that $S^{-1}R$ is the direct limit of $\mathscr O_X(X_s)=R_s$ (localizations of $R$ at ${1,s,s^2,\dots}$) for those $s$ that don't vanish on $U$.
However, the actual definition of the sheaf requires that $\mathscr O_X(U)$ be the inverse limit of $\mathscr O_X(X_f)=R_f$ for those $f$ that vanish on the every point of the complement of $U$ (i.e. for $f$ such that $X_f\subset U$).
Evidently, the former admits a unique morphism into the latter, as the former is an initial object and the latter a terminal object. I strongly suspect that the two constructions are different in general (otherwise why torture us beginners with the counter-intuitive inverse limit definition), but I have been unable to come up with an example where the two diverge.

REPLY [2 votes]: Let $R$ be a boolean ring (every element is idempotent). It is easy to see that every localization map $R \to S^{-1} R$ is surjective. But not every restriction map $R = \mathcal{O}(\mathrm{Spec}(R)) \to \mathcal{O}(U)$ is surjective: 
Let $R$ be the unitalization of the $\mathbb{F}_2$-algebra $\mathbb{F}_2^{(\mathbb{N})}$. It maybe regarded as the subring of $\mathbb{F}_2^\mathbb{N}$ generated by the standard basis vectors $e_1,e_2,...$. The restriction map to $U = \cup_i D(e_i)$ corresponds to the inclusion $R \hookrightarrow \mathbb{F}_2^\mathbb{N}$. It is not surjective (for example, $(1,0,1,0,1,...)$ is not in the image).
By the way, $\mathrm{Spec}(R)$ is the one-point-compactification of $U=\mathbb{N}$, endowed with the constant sheaf $\underline{\mathbb{F}_2}$.