I’m about to write my first (test) project with Julia. I have installed Juno and , because I saw that is the “standard” for development. I have entered examples from the official Julia documentation into a REPL prompt so far. Now I need some help to make this more productive.
I’m looking for these functions in Juno:
- Specify a “project”. Not just a plain directory, but a place where environment variables and “run configurations” can be setup etc. In other IDEs (eclipse, pycharm, intellij etc.) there are special files that describe the “current workspace” and its configuration. I’m looking for the same thing in Juno.
- A button or a shortcut to start a (previously configured) “run configuration”. For example, let’s say I’m working on a web service, and there is a main entry point for the project called “run.jl”. How can I create a run configuration/shortcut that I can activate when I want to compile and start it?
- When an exception is thrown, ideally I should be able to click on the source code references on the traceback and navigate to the source code. Is this possible?
- It is not entirely related, but I wonder if I can assign my own shortcuts to functions? For example, I have noticed a “format code” menu in Juno. It works fine, but it does not have a shortcut.
I’m assuming when you say Juno you mean you installed uber-juno in Atom.
- Run Julia in the parent directory of your “project” folder. Enter “
] generate MyProject
” (Don’t miss the square bracket at the front. This will create a folder called “MyProject” and create the initial Julia project files in it. Open this folder in Atom.
- Not sure if there is a way to do this. My projects have an “master” file that I run in Julia. It includes all the other files that it needs to do whatever the task is. So when I want to start my program I open that file and Click “Run All” or hit Ctrl+Shift+Enter.
- Yes you can click on a file path displayed in REPL and Atom will open that file and jump to the line number.
- Creating shortcuts in Atom: Basic Customization
1 Like
Thank you. About the second point: running a file and running a run configuration is not the same. Imagine a program that has command line options, and uses environment variables etc. A run configuration can run a command, with a given set of environment variables, with the current directory set to a given value etc.
So yes, this is a bit different than just running a single file, but I can find out something around this.
Yeah I’m not sure how to do that dynamically. That would imply passing parameters to Julia when it’s started in the REPL. You could probably set those parameters under the plugin’s configuration but that would apply to all projects and would not be simple to change if you are jumping back and forth between two different set of arguments.
I have created a new project with ] generate MyProject
and opened its directory with Juno. The problem I’m having is that whenever Juno starts a new julia REPL, it is not using this project.
For example, if I do “st” in pkg then I get this:
(@v1.4) pkg> st
Status `C:\Users\my_user_name\.julia\environments\v1.4\Project.toml`
If I try to add a package as a dependency, it will add it to to that project, and not MyProject
. The REPL needs to be restarted frequently while I’m developing, and I think it should use the project by default that is opened in Juno.
But I don’t see how to set this up?
Thanks
Actually, if Atom could set JULIA_PROJECT environment variable to a predefined value for me, then that would in turn use @ in Base.LOAD_PATH point to my project.
I found this post Activate project in Juno/Atom - #2 by pfitzseb that is about the very same thing. That topic was opened more than a year ago. There must already be a way to do this, just I can’t find it.
There is a workaround that actually works: open a shell, set JULIA_PROJECT env there, and start atom from that environment. It kind of works, but it makes switching projects from Atom impossible.
Actually, I am always typing first ] activate .
to activate the current environment in a new REPL. It works, but if there is a better way to do it I would like to know it, too.
In addition, you should use https://github.com/timholy/Revise.jl, so that you do not need to restart the REPL after each change in your module.
For generating a new package, GitHub - invenia/PkgTemplates.jl: Create new Julia packages, the easy way provides some more functionality than Pkg.generate
.
2 Likes
What I’ve done is create the file ~/.julia/config/juno_startup.jl
with the contents:
if isfile("Project.toml")
using Pkg
Pkg.activate(pwd())
Pkg.instantiate()
end
Which checks if there is a Project.toml
file found in the directory, and if there is, activates it.
4 Likes
This is very good. Although, it only works if you start atom from a terminal/shell. I usually start atom with a launcher (shortcut on Windows and the window manager’s launcher on Linux), and it will never start up in the project’s home directory.
The perfect way would be to make atom set JULIA_PROJECT environment variable for that Atom window whenever I open a folder that contains a Project.toml file. E.g. if you open multiple Atom windows then have separate environments, so it would also be possible to open multiple projects at the same time.
In theory, Atom is hackable, so I guess this is possible to do, but I’m not sure how.
1 Like