Unroasted coffee beans in the pantry, several years old: roast, toss, or other use?
After that long, the beans are almost certainly stale. While it's true that aged coffee is a thing, four to ten years is very long time to age coffee and the opinions on aged coffee seem to be mixed at best. I say toss 'em, although you could compost them or even use them for arts and crafts, I wouldn't recommend them for human consumption. It's doubtful that anyone would be harmed, seeing as caffeine is a natural pesticide and that would keep any 'ick' from developing, it probably wouldn't be a very enjoyable cup of coffee.