The shifter must be in its lowest position with all of the cable out of the shifter when attaching the cable to the derailleur.
There should be no slack in the cable when the chain is on the smallest chainring.
It may be necessary to add some tension to the cable.