A serial offender from Dundee moved 80 miles to a rehabilitation unit, only to get into trouble again.
Barry Davies, 41, was caught after breaking into a shop and stealing perfume.
Davies, a prisoner, was jailed for 14 months at Hamilton Sheriff Court.
He admitted breaking into B&M in East Kilbride, Lanarkshire, on September 2.
His lawyer, James Caird, said Davies has drugs and mental health issues and had enrolled at a rehabilitation centre in Blantyre, Lanarkshire.
Mr Caird told the court: “He was desperate to do something about his drug problem.
“Unfortunately, funding was for only 12 weeks and no more was forthcoming.
“Eventually he moved to a hostel in East Kilbride where, he indicates, drugs were freely available.
“He was under the influence of drugs at the time of this break-in.
“He has a record, particularly for dishonesty – there is no getting away from that.”
Mr Caird said Davies intends to return to Dundee on his release from prison.
Stole perfume from store
Alice Carey, prosecuting, said a night shift worker heard glass breaking at 3am.
“A pane of glass had been smashed and a brick was lying at the side.
“Perfume was missing from cabinets in the store.
“Police were called and identified the accused from the store’s CCTV.
“He was stopped at 4am, carrying a bag that contained perfume worth £141.92.”
Passing sentence, Sheriff Linda Nicolson told Davies: “You have a significant record, including for housebreaking.
“I would have jailed you for 21 months but for your guilty plea.”
The 14-month prison stretch was backdated to September 5, as Davies has been in custody since his arrest.