Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make RCall.jl use a CondaPkg.jl environment? #113

Closed
3 tasks done
schlichtanders opened this issue Oct 20, 2023 · 8 comments
Closed
3 tasks done

How to make RCall.jl use a CondaPkg.jl environment? #113

schlichtanders opened this issue Oct 20, 2023 · 8 comments

Comments

@schlichtanders
Copy link

schlichtanders commented Oct 20, 2023

Hi,
this package is really really awesome! :)

I would like to also use RCall on top of it, however for this I seem to need Conda.jl. Hence I would like to let it make Conda.jl use my current CondaPkg.jl environment.

Conda.jl documentation tells:

  1. set ENV["CONDA_JL_HOME"] to the environment (which will become Conda.jl root environment, which should be the one picked up by RCall / PyCall)
  2. set ENV["CONDA_JL_CONDA_EXE"] to the executable in order to not install two different condas
  3. rebuild Conda.jl and respective dependencies

My status:

  • 1. I guess this is corresponds to CondaPkg.jl ENV["JULIA_CONDAPKG_ENV"], which I already set
  • 2. I guess this is corresponds to CondaPkg.MicroMamba.executable()
  • 3. rebuilding is okay for me, because I am using a fixed conda environment per julia process

So it happens by writing this issue, I have solved kind of a couple of steps myself :)
Maybe someone can check whether this makes sense, or whether I overlooked something.

I will try it out myself soon and report in this issue.

@schlichtanders
Copy link
Author

Short remark: When simple using R, it is probably sufficient to just set

ENV["R_HOME"] = CondaPkg.envdir() * "/lib/R"

and rebuild RCall (Probably a similar approach also works for PyCall)

@schlichtanders schlichtanders changed the title How to make Conda.jl use a CondaPkg.jl environment? How to make ~~Conda.jl~~ RCall.jl use a CondaPkg.jl environment? Oct 20, 2023
@schlichtanders schlichtanders changed the title How to make ~~Conda.jl~~ RCall.jl use a CondaPkg.jl environment? How to make RCall.jl use a CondaPkg.jl environment? Oct 20, 2023
@schlichtanders
Copy link
Author

schlichtanders commented Oct 20, 2023

I tried running the following

julia> using CondaPkg

julia> ENV["R_HOME"] = CondaPkg.envdir() * "/lib/R"

julia> import Pkg

julia> Pkg.build("RCall")

julia> import RCall
┌ Warning: RCall.jl: During startup - Warning messages:1: package ‘utils’ in options("defaultPackages") was not found 
│ 2: package ‘stats’ in options("defaultPackages") was not found 
└ @ RCall ~/.julia/packages/RCall/gOwEW/src/io.jl:172

The CondaPkg environment does not have a proper R setup... I am confused. Any help is highly appreciated


Edit: CondaPkg.status() looks good

julia> CondaPkg.status()
CondaPkg Status /home/ssahm/Tmp/tmp-julia/condapkg/CondaPkg.toml
Environment
  /home/ssahm/Tmp/tmp-julia/condapkg/.CondaPkg/env
Packages
  r-base v4.3.1
  r-codedepends v0.6.5
  r-globals v0.16.2
Channels
  bioconda
  conda-forge

@schlichtanders
Copy link
Author

schlichtanders commented Oct 20, 2023

@simonbyrne maybe you can help?

EDIT: This last error rather looks like this issue could be migrated to RCall.jl actually

@simonbyrne
Copy link

Unfortunately, I'm afraid I haven't looked at RCall.jl for some time, and my bandwidth is rather limited at the moment.

@cjdoris
Copy link
Collaborator

cjdoris commented Oct 20, 2023

Perhaps you need to activate the Conda environment in your Julia session first like PythonCall does here: https://github.com/JuliaPy/PythonCall.jl/blob/0056de8711e274b3d8084d19a23fe54adf5d0640/src/cpython/context.jl#L68

@schlichtanders
Copy link
Author

Thank you for your comments. It turned out it was a linux distribution specific problem which is already reported at anaconda. Concretely you need to have /usr/bin/which available on your system for R...

It works now that I've symlinked /usr/bin/which

@schlichtanders
Copy link
Author

related issue: JuliaInterop/RCall.jl#480 (tries to improve RCall.jl for better integration with CondaPkg.jl without the need of Pkg.build("RCall"))

@schlichtanders
Copy link
Author

Short remark: When simple using R, it is probably sufficient to just set

ENV["R_HOME"] = CondaPkg.envdir() * "/lib/R"

and rebuild RCall (Probably a similar approach also works for PyCall)

this is the final way I am using

import CondaPkg
ENV["R_HOME"] = CondaPkg.envdir() * "/lib/R"
import Pkg
Pkg.build("RCall")
using RCall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants