Is spring force really a conservative force? Let us consider this picture.

$\Rightarrow$ The first picture shows the initial position of the block when the spring is in its natural length and is kept on a smooth horizontal table.
$\Rightarrow$ The second figure corresponds to the situation in which the block is pulled straight on the smooth horizontal table from its natural length (indicated by the first dashed line).
$\Rightarrow$ The third figure corresponds to the situation in which the spring is first pulled and is then turned around a hinged nail and is then brought to the same final position as it is in the second figure     (indicated by the second dashed line).
The block is moved on the horizontal table only and is not pulled vertically in any of the figures.
So in picture (b) and (c) the initial and final positions of the block is same but I don't think the spring potential energy is equal in both the cases.
Surely the spring elongated more in the third case so it stores more potential energy but we also know that the potential energy is equal to the negative of the work done by conservative forces so doesn't this mean that the work done by the spring depends on the path on which the block travels?
Can someone explain what is happening here? Where am I wrong?
 A: The issue that you are running into is that the system in the third case is more complicated than in the first and second cases. In the first and second cases the position of the block is sufficient to determine the amount of energy stored in the spring, so that would be two generalized coordinates.
In the third case more generalized coordinates are required to specify the state of the system. I would use two additional coordinates identifying the position of the pin on the plane and then another to identify what part of the spring is pinned. However, it is certainly possible to use different coordinates if you like.
In this larger parameter space it is clear that the work done by the spring is independent of the path taken to get there. There is a potential energy that depends only on these generalized coordinates, and not the velocity nor the history. The force is conservative.
A: It is conservative, it depends on the path, although the dependence of the force with $x$ is different just because the configuration is different. in case (3) the horizontal force is $F=-kx\sqrt{H^2+x^2}/H$, if H is the height of the hinge and the string is always straight (we also assume that the mass does not move along $y$, also assumed was rest lenght=0).
A: The position of the block is the same in both cases, but the position of the block does not wholey define the potential energy in the spring.   The length the spring is stretched defines the potential energy (along with the spring's coefficient).
If you don't change the setup of the system, you can say that the position of the block defines the length of the spring, because you can find the length of the spring given any arbitrary block position.  However, in (c) you change the system by dragging it around a nail.  Now, instead of being a straight line between the wall and the block, the spring follows the two diagonal lines.  The sum of the length of those two diagonals is longer than the length of the straight line, so the spring has more potential energy stored in it.
Another way you can see the same effect is if you were to start with case (b), and then use a rod to stretch the spring upwards, until it is just as in (c).  Intuitively you will have to put work into that spring, so the system must be gaining energy.
A: You have to remember that the energy is "stored" in the spring. The block doesn't have the potential energy. The energy of the third system isn't only dependent on the position of the block (or, more specifically, the right end of the spring). You had to do work to move the middle of the spring to the hinge. You need to take this energy into account as well.
A: I think that you are confused about what "independent of path" means. For conservative forces the work done between two STATES of the system is independent of path.  We also can define a potential energy which is a function of the state of the system. In your case,  elastic PE is a function of the state of the spring.  This is the system with elastic PE.  It is obvious that your (b) and (c) represent two distinct states of the spring so the work done going from (a) to (b) has no reason to be equal to the work done from (a) to (c). The path independence just refers to one pair of states.  Not that going from an initial state to any other state you do the same work.
