How do I create a src folder for my environment?

I created a new environment following these the steps in 4. Working with Environments · Pkg.jl

After that I told VSCode to use that environment by moving to it using the Explorer in VSCode and using the VSCode command Activate This Environment.

So far so good. But I noticed there is no src folder in the new environment. Should I create one manually or am I missing something?

I suppose you are trying to develop a package since you are interested in having a src folder?
Try looking at 5. Creating Packages · Pkg.jl on how to automate having a structured folder for development,

If you want even more control and customization on what to generate for your package/development environment, have a look at GitHub - invenia/PkgTemplates.jl: Create new Julia packages, the easy way, but I’d say that the basic generate is plenty good for starting to explore


Thanks. Just right off the bat you have helped me. Actually I am not trying to develop a package. I just thought I would need a src folder because I have seen src folders elsewhere. But if I do not need a src folder where do I put my source files? Right in the environment folder? Could I still create a src folder as a subfolder of the project folder and put my source files there for better organization?

An environment is not really tied to any file/folder structure, you can also have your source files using a specific environment in a completely different folder and just activate the correct environment by pointing to it.
You can create a src subfolder or simply put the source files in the folder of the environment (the environment is just specified by the Project.toml).

I would still suggest you to try and generate a package structure for your tests, it directly creates a source subfolder and allows you to then re-use your code when you think it is in a good state by just using it. On top of easing up an eventual publication of your experimentation for other people to use.

You are right. Learning how to create packages is in my agenda. However, my previous attempts failed. I took note of the URL you recommended and will give it another try ASAP.

You don’t need to do anything.

When you start Julia it activates the default environment and you can start typing away at the REPL.

If you want to bring in some code you can include(“path/to/file”) and it will be as if you typed it all in.

I’ve been using Julia for years and only recently started using custom environments.

You can have a folder of your own packages without using the package template, just this works:

$ mkdir /tmp/pkgs
$ echo "module ModuleName1 end" > /tmp/pkgs/ModuleName1.jl
$ echo "module ModuleName2 end" > /tmp/pkgs/ModuleName2.jl
$ echo 'push!(LOAD_PATH, "/tmp/pkgs")' >> ~/.julia/config/startup.jl
$ julia -q
julia> using ModuleName2
[ Info: Precompiling ModuleName2 [top-level]