I have just bought a new computer, which is a MacBook Air with an M3 chip. Ever since installing Julia and adding the extension via Visual Studio Code I receive errors such as "UndefVarError: ‘…’ not defined in ‘Main.xxx’.
I have never had this issue on my last computer, which was also a Mac. Does anyone have an idea how to solve this?
Then you are probably missing packages, that you installed on the previous machine, see theusing commands in your script. You have to reinstall those as well.
I have added the packages with using Pkg followed by Pkg.add(“package_name”). I can make the code run, but I get the error “UndefVarError: xxx is not defined in main” more often now compared on my last computer. Is that normal or is it only happening to me because I have done an installation error of Julia?
As mentioned above by @nsajko and @kellertuer, in order to actually help you you will need to provide more details. Please read the link given by @nsajko.
I don’t think that example is complete enough to enable anyone to help you. You should try to provide a reproducer that’s complete, e.g. an entire file. But also try to minimize it, removing irrelevant details.
You probably meant to format multiple lines there between triple backticks, like this but without the brackets (I added those to stop the formatting)
[```]
include(“CrewPairingDataStructsExample2024.jl”)
using .CrewPairingDataStructsExample2024
[```]
The error you mentioned only hints that the module of that name failed to be instantiated. We’ll need to see what the file’s code and the full error stacktraces to know what’s going wrong there, it’ll help if you reduce it as much as possible without eliminating the errors so it’s easy to share and debug. Reducing would be removing definitions, function calls, and especially imports of other packages. If you reduce something, and running the file eliminates the error, then keep it and comment that it’s needed for that particular error.