stefan-m-lenz / JuliaConnectoR

A functionally oriented interface for calling Julia from R
Other
102 stars 6 forks source link

Starting Julia with a specific project environment #26

Closed msainsburydale closed 1 year ago

msainsburydale commented 1 year ago

First, thanks very much for the package, it works very well!

Is it possible to begin the Julia session from R with a specific project environment (i.e., a project encapsulated in Project.toml and Manifest.toml files)? Usually when working with Julia in terminal, I would start it with julia --project=. to start Julia with the environment of the working directory, but I'm not sure how to do this with JuliaConnectoR.

Thanks in advance!

stefan-m-lenz commented 1 year ago

Thank you, it is great to hear that you find the package useful!

Indeed there is a feature that allows this. You find the documentation of the feature in the package documentation in the section "EnvVars-JuliaConnectoR":

You can achieve your goal by setting the environment variable JULIACONNECTOR_JULIAOPTS. Citation from the documentation:

JULIACONNECTOR_JULIAOPTS: Set start-up options for Julia. As an example, consider specifying the project environment and enabling code coverage when starting Julia. This can be achieved by setting the environment variable to "--project=/path/to/project --code-coverage".

So for your example, you can set

Sys.setenv("JULIACONNECTOR_JULIAOPTS" = "--project=/path/to/project")

before connecting to Julia. Then the project will be used.

msainsburydale commented 1 year ago

Great, many thanks!