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.



Is a projective module of constant finite rank finitely generated?
For any commutative ring $R$ with 1, any projective $R$-module of constant finite rank is finitely generated. This is the content of Exercises I.2.13 and I.2.14 of Weibel's $K$-book. 
The argument goes as follows (all the relevant hints are in Weibel's book), I hope I did not introduce any tacit finiteness assumptions.


1) In the constant rank one case, we have the dual $\check{P}=\operatorname{Hom}\_R(P,R)$ and the evaluation map $\operatorname{ev}:\check{P}\otimes\_R P\to R$ whose image $\tau\_P=\operatorname{im}\left(\operatorname{ev}:\check{P}\otimes\_RP\to R\right)$ is called the trace. By a result of Kaplansky, $P\_{\mathfrak{p}}$ is free for any prime ideal $\mathfrak{p}\subseteq R$, and we can choose a generator $x\in P\_{\mathfrak{p}}$. Then $\check{x}\otimes x\mapsto 1$ under $\check{P\_{\mathfrak{p}}}\otimes\_{R\_{\mathfrak{p}}}P\_{\mathfrak{p}}\to R\_{\mathfrak{p}}$. In particular, $\tau\_P\not\subseteq\mathfrak{p}$ since otherwise $P\otimes\_R R/\mathfrak{p}=0$ contradicts the constant rank one assumption (as pointed out in the comments of Owen Biesel). Since $\tau\_P$ is an ideal, it contains $1$ and we can write $1=\sum f\_i(x\_i)$. For each $\mathfrak{p}$, some $x\_i$ will be a generator of $P\_{\mathfrak{p}}$, so the $x\_i$ are generators for $P$.


2) If $P$ has constant rank $r$, then $\bigwedge^r P$ has constant rank one and by Step 1 has finitely many generators. These are of the form $\sum a\_i y\_{1i}\wedge\cdots\wedge y\_{ri}$ and the (finitely many) $y\_{ij}$ appearing generate $P$.


