First steps: Start Julia in a certain folder in VSCode

Hi (sorry, first day here),

I open a folder and get in the terminal just: PS D\andSoOn_theFolderPath >
To get to Julia (if one can say it like that) I have to run a lin of code of a program in my folder, what am I doing wrong?

If I set my Julia environment in the left corner of VSCode to anything else than my current folder I get the error (That occurs in many other questions as well): Julia package not part of your current environment. Is that bad? It seems to run that way, kind of.

What is the structure of your code tree?

Some past posts that might help:

1 Like

Hi, welcome!

Have you checked the manual to use Julia in VS Code?
https://www.julia-vscode.org/docs/stable/

If I got it right, you are stuck in the very first action: how to open a Julia REPL to run commands. You have the specific instructions for that in this page:
https://www.julia-vscode.org/docs/stable/userguide/runningcode/

Shortcut: Alt+J, Alt+O normally starts a Julia REPL, unless you have a particular configuration that changes such keybinding.

Hi,

my Path is for example this folder saved somewhere

From the question:

All I wanted is to run a Julia file, thats it. The example I tried is the link (PowerModels, but any would work for me, I just need an example), it does have a Project and Manifest file. I am in the right path, I guess, and I did activate and instantiated (what I think is the current folder with those files).

So to back up to the absolut beginning in VS Code: “File” → “Open Folder” and my Terminal Commant line shows PS D:\Daten\Julia\PowerModels.jl-master>
(… the cd(“D:\Daten\Julia\PowerModels.jl-master”) command then does nothing, right? But I should be in the working directory) I can change the environment in the left corner of VSCode and chose “C:\users\myName.julia\environments\v1.7”, but that doesnt help … and typing in “using Pkg” doesnt work in any case.
Runing one line of Code by Ctrl+enter in a file in that folder starts Julia and I can type in using Pkg and then activate and so on…

That cant be the way, right?
But that is also another problem due to inexperience, I hope.

I just want to run the Code, shown in the read me:

Basic Usage

Once PowerModels is installed, Ipopt is installed, and a network data file (e.g. “nesta_case3_lmbd.m”) has been acquired, an AC Optimal Power Flow can be executed with,

using PowerModels
using Ipopt
run_ac_opf(“nesta_case3_lmbd.m”, IpoptSolver())

Hello,

I have, but I will dig deeper, my specific Problem is posted as an answer to PetrKrysIUCSD here in this discussion, maybe thet helps to clarify. But I will dig deeper.
The way I try it seems just too hard for just running code.

Hi,

thank you, I will look into it.

Is there any reason to be using a six year old package that probably doesn’t work on recent Julia versions anways? I’d try GitHub - lanl-ansi/PowerModels.jl: A Julia/JuMP Package for Power Network Optimization instead if I were you.

That is the PowerShell terminal, nothing to do with Julia. What you are looking for is the REPL (which shows the julia> prompt), and you have to start it manually. That can be done in (at least) three ways:
a. Run the command “Julia: Start REPL” (from the command palette: Ctrl+Shift+P).
b. Default keybinding: Alt+J, Alt+O.
c. Run some code in the editor (the way you actually did it).

1 Like

Well, I open a normal terminal in vscode and start julia from that terminal… Faster and easier for me than using the Julia REPL from vscode…
And to run an example I just use the command

include "src/my_code.jl" 

or whatever…

Yes, that works, but other components of the VS Code Julia extension (inline execution, variable explorer, plot panel, automatic recognition of sysimage…) won’t be linked to what you do in that terminal. That’s ok if you like it like that, but may be confusing for new users who have read about those features.

1 Like

Hello,

there is not. Nice that you looked that up, but it was just an example and does therefore not tackle the main problem.
The new Version does look very interesting though, thx.

How about giving GitHub - PetrKryslUCSD/VSCode_Julia_portable: Portable Julia running in VSCode a shot?

Well, I do have a set file folder, structure
Folder(Project,Manifest,src(file1,file2),examples(example1,example2)).
I cannot just klick in examples, in example1 and go to “Run”.

include(“examples/example1.jl”) does not work, e.g. this and a 100 other Errors occur:
ERROR: LoadError: UndefVarError: VariablesContainer not defined

I am kind of confused.

Does it work if you just use the REPL without VSCode?
Can you share your file example1.jl?