Error when enabeling automatic differentiation in Optim

I try to enable forward automatic differentiation to the Rosenbrock example in the documentation (link). When setting the OnceDifferentiable object I get an error:

od = OnceDifferentiable(f, initial_x; autodiff = :forward)

MethodError: no method matching Optim.OnceDifferentiable(::#f, ::Array{Float64,1}; autodiff=:forward)
Closest candidates are:
Optim.OnceDifferentiable(::Any, ::Any, !Matched::Any) at…

Has there been made changes to how this is done, which has not been updated in the documentation?

What versions of Optim and Julia do you have?
Should work on Optim v0.9.x with Julia 0.6-

The API for earlier version was different.

Oh, actually I do not have the latest version, only v 0.7.8. But when I try Pkg.update("Optim") i get the following info:

Package Optim was set to version 0.7.8, but a higher version 0.9.3 exists.
The update is prevented by explicit requirements constraints. Edit your REQUIRE file to change this.

How do I fix this, or in other words how do i edit the REQUIRE file? thx

Your REQUIRE file is located in ~/.julia/v0.6 (on mac and linux, at least). On all platforms you should be able to find its folder with Pkg.dir(). Can you show us the contents of that file? For example, you can run readlines(joinpath(Pkg.dir(), "REQUIRE"))

I tried various things, including removing both LineSearches and Optim. But I was still not able to upgrade to the latest versions, so I ended up reinstalling Julia. Now it works.