Ferrier was born in Edinburgh on 7 August 1932. Following the family's idiosyncratic naming tradition, although he was named Robert John, he was always known as Robin. Likewise his father Edward was known as William and his mother Sophia was known as Rita. William was a policeman and became head of Edinburgh CID, while Rita was a housewife.
His only sibling was a fraternal twin sister Dr Barbara M. Ferrier (d. 2006), known as Ray, who likewise became an organic chemist, becoming professor emeritus of the Department of Biochemistry and Biomedical Sciences at McMaster University.  A polycyclic ketone "barbaralone", related to bullvalene was named after her.
Ferrier attended George Heriot's School for all of his schooling, apart from a brief time in Traquair, to where he was evacuated during the war with his mother and sister.
He gained a Bachelor of Science with first class honours in 1954 and a PhD in plant polysaccharides in 1957, under Professor Gerald Aspinall.