Crops can grow very well on the Moon and Mars
According to a recent study, all that potato growing that we saw in The Martian is scientifically possible. Researchers in the Netherlands decided to test the soils of Mars and the Moon to see if planting crops will be possible, once we build bases there.
They used Martian and Lunar soil simulates developed by NASA, with some organic materials added, and planted 10 different crops. They found that 9 of the 10 crops grew well in both soils, produced edible parts and viable seeds to re-plant.
They also have discovered materials to help the crops survive the radiation and extreme temperatures on both celestial bodies, to ensure a good harvest.