Ok so, first try manipulating the lever that's on your right, on the other side of the rails, so that the rails turn to the right at that point. Then, from what I saw from your first pic there's a minecart somewhere on your right that passes through the point that you can manipulate with the lever you're currently facing towards. Ride that minecart to wherever on the left side it gets you, then come back on foot to manipulate the lever you're facing to so the rail goes straight up, and then if you get back to the minecart you rode to the left side, you should be able to ride it to get to the spirit.
If it still doesn't work, you can link your save file and I can just get you there myself if you want to.