TITLE: If $M\oplus M$ is free, is $M$ free?
QUESTION [14 upvotes]: If $M$ is a module over a commutative ring $R$ with $1$, does $M\oplus M$ free, imply $M$ is free? I thought this should be true but I can't remember why, and I haven't managed to come up with a counterexample.
I apologize if this has already been answered elsewhere.

REPLY [2 votes]: For invertible ideals $I,J$ of a Dedekind ring $R$, it is well-known that $I \oplus J \cong R \oplus I \cdot J$ (see for example May's Notes on Dedekind rings, Prop 6.4). For the ideal $I = (2,1+\sqrt{-5})$ of $R=\mathbb{Z}[\sqrt{-5}]$ we have $I^2=(4,2+2 \sqrt{-5},-4+2 \sqrt{-5})=(2) \cong R$. Hence $I \oplus I \cong R^2$ is free, but $I$ is not free, since it is invertible and not principal.