Sheriff Isabella McColl said she had no other option but to send David Williamson to prison after he claimed he would go on using the class B drug once his case was dealt with.
Police were called to Williamson’s Sighthill home to investigate reports that he had been assaulted and robbed.
But he ended up in court for volunteering that the stolen property was two of his prized cannabis plants.
Edinburgh Sheriff Court yesterday heard claims Williamson, 34, confessed all to the police after his home had been raided by a gang of four men armed with guns. Officers got a warrant to search his home and discovered a further 20 plants.
Williamson admitted producing a controlled drug at his Sighthill home in May this year.