Compatibility issue between ControlSystems and SeeToDee?

I tried to run a program which uses ControlSystems and SeeToDee at the same time but I never managed to make it work. I am using Julia in Visual Studio Code. I tried many many different things and none of them work. Here is a very shorl list of what I have tried : change Julia environment from 1.8 to 1.9, remove and add ControlSystems and/or SeeToDee pakages within VS Code, or within Julia 1.9.4 IDE, uninstall/reinstall Julia module from VSCode, run using REPL, run using new process, use only ControlSystems, use only SeeToDee, suppress lines of codes calling SeeToDee.Rk4(…), add Polynomials and/or Makie and/or MakieCore (because of an error when precompiling ControlSystems when SeeToDee was installed).
I have spent many evenings trying to solve this issue, and it still doesn’ t work.

In summary I have two types of errors: either
1/ When there is an attempt to precompile ControlSystems there is an error related to Polynomials which doesn’ t have MakieCore in its dependencies. Does ControlSystems really need Polynomials ? That’s the reason why I tried to install Polynomials together with Makie, but it was not sufficient as I still have the same issue

2/ When trying to add SeeToDee under VS Code, I get the error Unsatisfiable requirements detected for package SeeToDee [1c904df7]
with the following log:
possible versions are 1.0.0-1.2.0 or uninstalled
restricted to versions * by an explicit requirement, leaving only versions 1.0.0-1.2.0
restricted by julia compatibility requirements to versions: uninstalled – no version left
I tried t install SeeToDee from Julia IDE, and I have no issue frm this IDE, but when I come back to VS Code, I get the issue 1/ mentionned above

Very frustrating.

BTW, here is the code:

using ControlSystems
using SeeToDee

begin

  • function motor(x, u, p, t)

  •    τ = p[1]
    
  •    b = 2.0
    
  •    SA[
    
  •        -τ*x+b*u[1]
    
  •    ]
    
  • end

  • measurement(x,u,p,t) = SA[x[1]]

  • Ts = 0.1

  • discrete_dynamics = SeeToDee.Rk4(motor, Ts, supersample=2)

*end
Can someone help me ?

Hello,
I tried:

mkdir Control
cd Control
julia --project="."
using Pkg
Pkg.add("ControlSystemsBase")
Pkg.add("SeeToDee")

which worked fine.

I wrote a file sim.jl eith the content:

using ControlSystemsBase
using SeeToDee
function motor(x, u, p, t)
    τ = p[1]
    b = 2.0
    SA[-τ*x+b*u[1]]
end
measurement(x,u,p,t) = SA[x[1]]
Ts = 0.1
discrete_dynamics = SeeToDee.Rk4(motor, Ts, supersample=2)

started Julia with julia --project and executed it:

julia> include("sim.jl")
SeeToDee.Rk4{typeof(motor), Float64}(motor, 0.1, 2)

Does this works for you?
If not, what is the error message?

Finally, if you post code please include it in triple backticks: ```

I also tried installing these two packages together and it worked fine

(jl_GlXGlK) pkg> add SeeToDee ControlSystems
    Updating registry at `~/.julia/registries/JuliaComputingRegistry.toml`
    Updating registry at `~/.julia/registries/JuliaHubRegistry.toml`
   Resolving package versions...
   Installed DiffEqCallbacks ────── v2.35.0
   Installed FFTW ───────────────── v1.7.2
   Installed StaticArrayInterface ─ v1.5.0
   Installed LinearSolve ────────── v2.21.0
   Installed DelayDiffEq ────────── v5.44.0
   Installed DiffEqBase ─────────── v6.143.0
   Installed Adapt ──────────────── v3.7.2
   Installed ControlSystemsBase ─── v1.10.1
   Installed PreallocationTools ─── v0.4.13
   Installed SciMLBase ──────────── v2.10.0
   Installed ControlSystems ─────── v1.10.0
   Installed FillArrays ─────────── v1.9.3
   Installed SparseDiffTools ────── v2.14.0
    Updating `/tmp/jl_GlXGlK/Project.toml`
  [a6e380b2] + ControlSystems v1.10.0
  [1c904df7] + SeeToDee v1.2.0

In fact, I have multiple packages that are dependents of both SeeToDee and ControlSystems so I know that it works in all of these places.

When there is a package-environment issue, it’s really hard to provide much help without knowing what julia version you are using and what your package environment looks like. What does Pkg.status() output in the environment that fails precompiling?

Yes, a transfer function is represented as a ratio between two polynomials. Several algorithms on transfer functions are implemented in terms of algorithms on polynomials.

Thank you for your help.

I used another computer with a fresh install of Julia (1.9.4), and a fresh install of Julia extension within VS Code. Note that Julia had never been installed on this other computer before.

I also install the ControlSystems and SeeToDee packages through the Julia desktop environment (i.e. NOT through VS Code) (i.e. the one with the shortcut icon with the 3x colored circles): using ] pkg> add ControlSystems and SeeToDee. Everything went fine through this installation on this environment.

Then I switched to VS Code, where I created a new directory and created the new “sim.jl” file with the small code already described in previous email. Then, within VS code, I clicked on the top right arrow which, I guess, launched Julia in REPL mode, and … it worked fine !

This evening, I will try to do the same on the laptop where I had the issue, after removing Julia => Do you know how to completely remove Julia including the packages, and the configuration files (registry files, etc…) ?

Thanks again.

Well, there are no registry files. Deleting the folder .julia in your home directory is sufficient. But again, if you use an environment per project instead of a global environment this is probably not needed. See: Working with Julia projects | Julia programming notes

Thanks again.

So I went back to the other laptop and followed your advices. Now it works and in order to trace it I would like to give some information in case someone encounters the same issue.

After having created externally the directories mentionned in the link you sent about “Projects in Julia”, and adding the 2x packages “ControlSystems” and “SeeToDee”, I launched Visual Studio Code. Then, within Visual Studio, I created a terminal, then ‘cd’ to the src directory where the .jl file is (i.e. to …/src’), and from there I launched the program by clicking on the VS code arrow and use the “Run Code or Ctrl+Alt+N” menu selection to make it work with no error. The two other menus, i.e. “Julia:execute file in REPL” or “Julia:Run file in new process” don’ t work and give all the errors I mentionned in my very first mail, and which confused me in the first place.

Here is the beginning of the very long error message I get when clicking on Run file in new process:
‘’'ERROR: LoadError: ArgumentError: Package Polynomials does not have MakieCore in its dependencies:

  • You may have a partially installed environment. Try Pkg.instantiate()
    to ensure all packages in the environment are installed.
  • Or, if you have Polynomials checked out for development and have
    added MakieCore as a dependency but haven’t updated your primary
    environment’s manifest file, try Pkg.resolve().
  • Otherwise you may need to report an issue with Polynomials
    Stacktrace:
    [1] macro expansion
    @ .\loading.jl:1167 [inlined]
    [2] macro expansion
    @ .\lock.jl:223 [inlined]
    [3] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1144
    [4] include(mod::Module, _path::String)
    @ Base .\Base.jl:419
    [5] include(x::String)
    @ Polynomials C:\Users\Fabrice.julia\packages\Polynomials\5ZhzG\src\Polynomials.jl:6
    [6] top-level scope
    @ C:\Users\Fabrice.julia\packages\Polynomials\5ZhzG\src\Polynomials.jl:64
    [7] include
    @ .\Base.jl:419 [inlined]
    [8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base .\loading.jl:1554’‘’

So it seems that the integration of Julia within VS Code is not perfect

A much more likely explanation is that your package environment that was active in the VScode was messed up. I have used these two packages together (I am the developer of both) for months in vscode without any issues. In fact, package environment problems like this are never related to the editor you use to run julia, only to the contents of your Project.toml and Manifest.toml files.

That is not true, you also have to activate the correct environment in VSCode… Or just launch Julia from a terminal in VSCode with julia --project because I never understand what VSCode is really doing (which Julia version it launches with which parameters) and run your script with include("src/myscript.jl") what I am doing…

Both workpackages work together within VS Code when running the code using the “Run Code” command (or Ctrl+Alt+N) but NOT when using the other two run commands (REPL and new process). I don’ t understand why. If there was an issue with the packages environment it would not work at all no ?

When using REPL command,for some reason VS Code tries first to precompile one of the packages , and this precompilation fails. I tried with another short code using DifferentialEquations packages and I got exactly the same behavior : it tries to precompile DifferentialEqualtions first but without success (very long error message).

I am trying to use REPL mode instead of “Ctrl+Alt+N” run method because I want to plot curves, and no plot appears. And according to a discussion, the only way to see the plots within VS Code is by running Julia in REPL mode.

Here is the beginning of the message I get when running in REPL mode (again there is no problem when using Ctrl+Alt+N command):
[ Info: Precompiling DifferentialEquations [0c46a032-eb83-5123-abaf-570d42b7fbaa]
ERROR: LoadError: ArgumentError: Package Compat does not have Dates in its dependencies:
- You may have a partially installed environment. Try Pkg.instantiate()

  • to ensure all packages in the environment are installed.*
    - Or, if you have Compat checked out for development and have
  • added Dates as a dependency but haven’t updated your primary*
  • environment’s manifest file, try Pkg.resolve().*
    - Otherwise you may need to report an issue with Compat
    Stacktrace:
  • [1] macro expansion*
  • @ .\loading.jl:1167 [inlined]*

I tried Pkg.instantiate() but it didn’t correct the error

You need to keep track of two different active environemtn in vscode, one is shown in the bottom bar on the left side
image
and this is the environment julia will start in when you start the julia process inside vscode. This active environement can be changed by pkg> activate just like from a standard terminal.

The other environment is related to the active module, the active module is shown in the bottom bar on the right-hand side. Here, I have Main as the active module.
image

The different commands running code may run in different modules causing them to behave differently. The “send to REPL” code always executes in the module activated in the repl, usually Main. The command that executes inline executes in the “active module” as indicated by the bottom bar.

Learn mode about this here Julia Environments · Julia in VS Code

At the end, I never managed to make it work using REPL. So I decided to remove completely Julia and VS code Julia extension from my laptop.

Then I reinstalled Julia 1.9.4 and then VS Code Julia extension. I recreated the hello world test and it worked with the three types of runs (REPL, Ctrl+Alt+N and new process.

I also created a “testPlot” project where I simply created a very simple file pltting a sine. And now I have the opposite : it works in REPL but it doesn’ t work in Ctrl+Alt+N. In the latter case, I get the following message

[Running] julia “c:\Users\Fabrice\Documents\Julia\PLOTS\testPlots.jl”
ERROR: LoadError: ArgumentError: Package Plots not found in current path.

  • Run import Pkg; Pkg.add("Plots") to install the Plots package.
    Stacktrace:
    [1] macro expansion
    @ .\loading.jl:1630 [inlined]
    [2] macro expansion
    @ .\lock.jl:267 [inlined]
    [3] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1611

As you may have guessed, I have used the command proposed in the message but it doesn’ t work. I checked the environment message at the bottom of the VSCode windw and it seems to be correct (Julia env:PLOTS)
Now, do you know what could be the origin of this problem ?

Just in case here is the code
using Plots

x = range(0,10, length=100)

y = sin.(x)

plot(x,y)

Just don’t use the VSCode Julia integration for more than syntax highlighting and “goto definition”. Just use the normal VSCode terminal and start Julia from the terminal, and you won’t have any such troubles any more…

If you activate the package mode in the vscode REPL, what environment does that say you are in?

When I launch the command “Julia:Execute active file in REPL” in the menu appearing when clicking on the top right arrow in VS Code (so what I called REPL mode), and, after the successfull run when I click on the “]” key to go to pkg mode at the julia green prompt, I get the (PLOTS) pkg> prompt (in blue). So, if I understand well, it seems that the package environment used in REPL mode is correct which makes sense as it works