The singer Pete Doherty has escaped jail after a judge decided to defer sentencing him for drugs offences on condition he goes into rehab.
A warrant was issued for Doherty's arrest because he was late
Doherty earlier pleaded guilty to possessing crack cocaine and heroin at West London Magistrates' Court.
He was warned by Judge Davinder Lachhar that he would go into custody if he failed to take up a place he was offered on a detox programme.
Doherty, 28, pleaded guilty to four counts of possessing illegal drugs.
As well as crack cocaine and heroin, he also pleaded guilty to possessing quantities of cannabis and ketamine as well as to two driving offences.
Earlier, a warrant was issued for his arrest because he was more than two hours late for his hearing.
But the singer finally arrived and waded through a crowd of photographers into the court house.
At court the judge told him: "If you go to this place to have detox and take advantage of it then we will see what sentence is appropriate when you next come."
"But if you do not I can tell you now that you will go into custody."
He was charged after he was stopped in a car by officers in Kensington High Street, west London, on 5 May.
Doherty has appeared in court on a number of drug offences over the past nine months and was praised in April by District Judge Jane McIvor at Thames Magistrates' Court for "more than co-operating" in his struggle to beat his addiction to illegal substances.