WHAT COULD GO WRONG? San Francisco is finally building tiny cabins for homeless people. One reason: it may be cheaper than tents.

After years of resistance, San Francisco is finally jumping onto the trend of sheltering homeless people in tiny homes, with plans to install them on two parking lots about nine blocks away from City Hall.

The lots at 33 Gough St., between Market and Mission streets, have been used since December as a city-sanctioned “safe sleeping village,” holding 44 tents for unhoused people while they get counseling aimed at routing them into permanent homes. Those tents will be replaced by late fall with 70 tiny homes, dubbed cabins, similar to those already in use for years in Oakland, the Peninsula and San Jose.

Each 64-square-foot cabin will have a steel frame, 2-inch-thick walls, heat, a desk, a bed and a window. The revamped village will get improved bathrooms, storage spaces and a dining area.

The cost of up to $1.7 million for building and installing the cabins, along with the dining and other facilities, will be paid for by the nonprofits DignityMoves and Tipping Point Community. The cabins will remain for 18 months, when the lease the city signed for using the parking lots as outdoor shelter spaces runs out.

Related: It’s mental health, stupid: How Team Biden misunderstands homeless crisis.

What links all these troubled populations is a desperate need for treatment. There was a time not long ago when we understood this — and every state maintained an extensive network of residential psychiatric hospitals to provide care, or at least try to do so.

Now tent encampments (and jails and prisons) have replaced those inpatient facilities. The Treatment Advocacy Center reports that 20 percent of those in jails and 15 percent of those in prisons are estimated to suffer from serious mental illness: “Los Angeles County Jail, Chicago’s Cook County Jail and New York’s Riker’s Island Jail each hold more mentally ill inmates than any remaining psychiatric hospital in the United States.”

The total behind bars: as many as 383,000.

These are unfortunate souls who could be helped by treatment — but who lack the financial means to get private care or a practical publicly supported alternative. In other cases, their disease itself prevents them from realizing they need help, and the autonomy-obsessed, libertarian approach pushed by activists bars governments from offering involuntary inpatient treatment.

Exit quote: “We don’t leave those suffering from most ailments to forage for food from garbage cans, as many homeless must. We provide treatment, including through Medicare and Medicaid. Yet we pretend that the mentally ill, addicted souls on our streets just need more government housing. They are being cruelly used by subsidized-housing advocates, the activists who first started applying the very term homeless to them and who believe that government-provided housing is the universal substitute for a flawed private housing market.”