功亏一篑

gōng kuī yī kuì

lit. to ruin the enterprise for the sake of one basketful

to fail through lack of a final effort; to spoil the ship for a ha'penny worth of tar (idiom)

功

gōng

meritorious deed or service

亏

kuī

to lose (money); to have a deficit

一

yī

one

篑

kuì

basket for carrying soil