Lithuanian born Rimas Taminskas, 20, owed about £1,600 for accommodation after losing his part-time job.
He escaped empty handed from the shop after the owner’s wife hit him over the head with a tin of spaghetti.
He admitted attempted robbery and possessing an imitation firearm with intent and was sent to a Young Offenders’ Institute for three years.
Prosecutor Terry Holder told Exeter Crown Court Taminskas had been studying economics and politics at Exeter University.
But a few months before the raid in June, Taminskas had lost his job and his debts had mounted.
He bought a plastic gun and sprayed it with black paint and wore a hat, gloves and dark sunglasses in the raid on the store near the university.
Anna Midgeley, defending, said he was “a very talented young man who was too proud to ask for help”.”