Is this "Permanent magnet gun" real or fake? There are several videos on youtube describing linear accelerator built solely from permanent magnets, put like this:

I find it hard to believe that this can work because if it did, it would be exploitable to gain energy. Where would that energy come from then?
I think it's faked and that the magnet should find equilibrium in the middle of the contraption. Am I right or wrong?
I'm willing to test it if I don't get conclusive answer, but I thought I'd as first before wasting money on bunch of magnets.
 A: In the video I see that the author needs quite some force to load the gun. So here he puts the projectile in a high potential state, i.e. he provides the energy during the loading process. When released this energy accelerates the projectile. Hence, no violation of energy conservation.
Edit
Here a small representation with python and ten dipole magnets:

Top: field lines in top view. Bottom: x-Field (arb.u.) on projectile path.
If you came from the left you have to somewhat overcome the negative bump. You see that the last max is almost as high as the first min is deep. That's why lubricant is important, as metnioned by @xcoderx. Actually, the thing looks better if you make it shorter. On longer ones the max approaches a saturation value and you'll have more friction loss.
Extra
Just looked at the video again because the author inserts the magnet  as [NS] and [SN]. The behavior corresponds to the lower graph. In one case one has to overcome the first bump by pushing, but the total distance is not very much as the magnet is later attracted by the second bump. In the second case, the reversed magnet is attracted by the first bump, the author then pushes it over the second bump, which the naturally results in a larger distance. 
