I have the following problem:
We had to prove that if $R$ is a principal ideal domain we can "subtract" $R$ in direct sums of $R$-modules, i.e. $M_1 \oplus R \simeq M_2 \oplus R$ implies $M_1 \simeq M_2$.
Moreover we had the theorem that if $R$ is commutative (and not necessarily a PID) the rank of free R-modules is well-defined and had an example that this is not true for non-commutative rings. In particular, we obtain a counter example for above if $R$ is not commutative.
I now wonder if there is an example of a commutative ring $R$ and $R$-modules $M_1, M_2$ such that $M_1 \oplus R \simeq M_2 \oplus R$ but $M_1 \not\simeq M_2$. In particular I wonder if there are integral domains and principal ideal rings which don't fulfill this property.
Two $R$-modules $M,N$ are said to be stably isomorphic, if there is some $k \geq 0$ such that $M \oplus R^k \cong N \oplus R^k$. $M$ is stably free, if $M \oplus R^k$ is free for some $k$. So you are looking for modules which are stably isomorphic without being isomorphic. In particular, any stably free module which is not free would suffice.
In this paper, Keith Conrad gives an example of a stably free module $M$ which is not free: Let $R$ be the integral domain $\mathbb{R}[x,y,z]/(x^2+y^2+z^2-1)$, and $M = \{(a,b,c) \in R^3 : xa + yb + zc = 0\}$. Then $M \oplus R \cong R^3$ but $M \not \cong R^2$.