It's a bit expensive to get started, but a rack and weights will pay for itself in saved gym fees after a couple years, or a few months for 2 people somewhere expensive like SF. We managed to fit one back when my wife and I lived in 1 bedroom apartments.
> a rack and weights will pay for itself in saved gym fees after a couple years
That's been my solution.
If you take into account resale value, it'll actually pay itself off much faster - especially if you're willing to wait for good deals.
I think I was able to put together a full set of weights + another set of 45s for less than $1/lb. I'm using a cheap bar and a cheap rack, so the whole thing cost me less than $800.
I estimate that I could sell it all today for $600 for sure, and probably get back all my money if I was willing to wait 1-2 months.
The other big advantage of using a home gym is wait times; I used to go to a commercial gym, where the wait time for a rack was often more than 30 minutes at peak times. As long as you don't need machines (lat pulldown can be very nice), a rack at home can make gym time much more efficient.