If $R$ is a (commutative) ring and $P$ is a projective $R$-module, then every localization of $P$ at a prime of $R$ is free by Kaplansky's theorem, and has a well-defined rank. If these ranks are all finite, must $P$ be finitely generated?
The answer is no: one can take $R=k[x_1,x_2,\dots]/(x_1^2-x_1,x_2^2-x_2,\dots)$ and $P=\bigoplus_{n=1}^\infty R/\bigl(1-x_1x_2\cdots x_{n-1}(1-x_n)\bigr)$; then $P$ is projective, not finitely generated, and at each prime at most one of its summands is nonzero. At each prime $\mathfrak{p}$ of $R$, then, $P_\mathfrak{p}$ is a free rank-$1$ $R_\mathfrak{p}$-module, unless $\mathfrak{p}=(1-x_1,1-x_2,\dots)$, for which $P_\mathfrak{p}=0$.
Or here's another example: let $R$ be the ring of continuous functions $[0,1]\to\mathbb{R}$, and let $P\subseteq R$ be the ideal consisting of those functions that vanish on a neighborhood of zero. Then again $P_\mathfrak{p}$ is free of rank 1 at every prime $\mathfrak{p}$ of $R$, except for those $\mathfrak{p}$ consisting of functions vanishing at $0$; at such $\mathfrak{p}$ we have $P_\mathfrak{p}=0$.
Such examples must be reasonably complicated due to this result of Bass's:
Proposition 4.2. Suppose $R$ has only finitely many primes minimal above $0$... If $P$ is a locally finitely generated projective $R$-module, then $P$ itself is finitely generated.
("Big Projective Modules are Free", 1963)
However, I'm wondering if it's possible to remove the conditions on $R$ if we assume not only that $P$ is projective, but that its rank is a continuous function $\mathrm{Spec}(R)\to \mathbb{N}$. Since continuity of the rank function is equivalent to the rank being locally constant, we can work locally on affine opens where the rank is constant. Thus the question reduces to:
If $P$ is a projective $R$-module of constant finite rank, is $P$ finitely generated?
Thanks for your input.