# NonlinearSolve.jl - 'solve' not defined

**URL:** https://discourse.julialang.org/t/nonlinearsolve-jl-solve-not-defined/113020
**Category:** New to Julia
**Created:** [April 16, 2024, 2:37pm UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-solve-not-defined/113020 "2024-04-16T14:37:40Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Giovanni\_Bettolo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giovanni_bettolo/32/208531_2.png) [@Giovanni\_Bettolo](https://discourse.julialang.org/u/Giovanni_Bettolo)
#### Post date: [April 16, 2024, 2:37pm UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-solve-not-defined/113020/1 "2024-04-16T14:37:40Z")

</div>

I am new to Julia, I have been trying to test the NonlinearSolve.jl installation using the Problem Type 1 of “Getting Started with Nonlinear Rootfinding in Julia”, but it always returns the error ’LoadError: UndefVarError: solve not defined’. I am not able to figure out why. I installed the last version of Julia from Microsoft Repository and installed the NonlinearSolve.jl without any warning or error. Could anyone please help me. I have included the test code here.

```julia
using NonlinearSolve

f(u, p) = u .* u .- p
u0 = [1.0, 1.0]
p = 2.0
prob = NonlinearProblem(f, u0, p)
sol = solve(prob)

```

The NonlinearSolve version is v3.10.0

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [April 16, 2024, 2:58pm UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-solve-not-defined/113020/2 "2024-04-16T14:58:34Z")

</div>

Welcome to the forum!

If you share source code, please enclose it in triple backticks, like ``` for  
better readability.

I created a new project:

```julia
mkdir nlsolve
cd nlsolve
julia --project="."
using Pkg
pkg"add NonlinearSolve"

```

put your code into a file with the name `test.jl` and executed it.

julia --project

```julia
julia> include("test.jl")
retcode: Success
u: 2-element Vector{Float64}:
 1.4142135623730951
 1.4142135623730951

```

Content of the file `test.jl`:

```julia
using NonlinearSolve
f(u, p) = u .* u .- p
u0 = [1.0, 1.0]
p = 2.0
prob = NonlinearProblem(f, u0, p)
sol = solve(prob)

```

Seams to work fine for me…

Can you share:

- the output of the command `versioninfo()`
- the output of:

```julia
using Pkg
Pkg.status()

```

?

Perhaps this can give us a hint what is the reason of your problem…

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [April 16, 2024, 3:02pm UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-solve-not-defined/113020/3 "2024-04-16T15:02:11Z")

</div>

The thing that is incredibly strange here is that `solve` would not be defined after `using NonlinearSolve` runs successfully. I have a very hard time imagining how his could possibly happen.

---

<div class="post-metadata">

### Author: ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)
#### Post date: [April 16, 2024, 3:32pm UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-solve-not-defined/113020/4 "2024-04-16T15:32:21Z")

</div>

> [@ufechner7](#):
>
> ```julia
> mkdir nlsolve
> cd nlsolve
> 
> ```

This is not going to work on Windows.

* * *

The first question is where are you running Julia? Did you open the Julia application from the start menu or are you running Julia within another program like Visual Studio Code?  
(I suspect a [VSCode module issue](https://discourse.julialang.org/t/vscode-repl-namespaces-modules/103170).)

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [April 16, 2024, 3:41pm UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-solve-not-defined/113020/5 "2024-04-16T15:41:34Z")

</div>

> [@Nathan\_Boyer](#):
>
> This is not going to work on Windows.

It works fine on Windows, even with the old style DOS terminal…

---

<div class="post-metadata">

### Author: ![Giovanni\_Bettolo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giovanni_bettolo/32/208531_2.png) [@Giovanni\_Bettolo](https://discourse.julialang.org/u/Giovanni_Bettolo)
#### Post date: [April 16, 2024, 5:34pm UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-solve-not-defined/113020/6 "2024-04-16T17:34:33Z")

</div>

thank you for your reply. With your instructions the code is working. As stated from Nathan\_Boyer I was using Visual Studio Code, so I think is a problem of VSCode configuration. I will study the correct configuration.  
The output of the command versioninfo() is:

Julia Version 1.10.2  
Commit bd47eca2c8 (2024-03-01 10:14 UTC)  
Build Info:  
Official [https://julialang.org/](https://julialang.org/) release  
Platform Info:  
OS: Windows (x86\_64-w64-mingw32)  
CPU: 4 × Intel(R) Core™ i7-5500U CPU @ 2.40GHz  
WORD\_SIZE: 64  
LIBM: libopenlibm  
LLVM: libLLVM-15.0.7 (ORCJIT, broadwell)  
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

the output of Pkg.status() is:

Status `C:\Users\Giovanni\Julia programs\Project.toml`  
[8913a72c] NonlinearSolve v3.10.0
