# How to set JULIA\_PROJECT for JuliaCall?

**URL:** https://discourse.julialang.org/t/how-to-set-julia-project-for-juliacall/60408
**Category:** General Usage
**Tags:** question, juliacall
**Created:** [May 2, 2021, 4:02am UTC](https://discourse.julialang.org/t/how-to-set-julia-project-for-juliacall/60408 "2021-05-02T04:02:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)
#### Post date: [May 2, 2021, 4:02am UTC](https://discourse.julialang.org/t/how-to-set-julia-project-for-juliacall/60408/1 "2021-05-02T04:02:44Z")

</div>

I need access to a pre-existing project environment within JuliaCall.

The following MWE does not work:

### MWE:

#### Create the ‘pre-existing’ environment

```julia-auto
# run this in the terminal
$ cd ~/
$ mkdir /tmp/testenv && cd /tmp/testenv
$ julia
julia> using Pkg; Pkg.activate("/tmp/testenv")
julia> Pkg.add(DataFrames)

```

#### Accessing it in R [`testjuliacall.R`]

```julia-auto
# testjuliacall.R
library(JuliaCall)
Sys.setenv(JULIA_PROJECT="/tmp/testenv")
julia_library("DataFrames")

```

#### Problem

Running `testjuliacall.R` produces the following error:

```julia-auto
Julia version 1.6.0 at location /usr/local/julia-1.6.0/bin will be used.
Loading setup script for JuliaCall...
Finish loading setup script for JuliaCall.
Error: Error happens in Julia.
ArgumentError: Package DataFrames not found in current path:
- Run `import Pkg; Pkg.add("DataFrames")` to install the DataFrames package.

Stacktrace:
[1] require(into::Module, mod::Symbol)
@ Base ./loading.jl:871
[2] eval
@ ./boot.jl:360 [inlined]
[3] eval_string(x::String)
@ Main.JuliaCall ~/R/x86_64-pc-linux-gnu-library/4.0/JuliaCall/julia/setup.jl:195
[4] docall(call1::Ptr{Nothing})
@ Main.JuliaCall ~/R/x86_64-pc-linux-gnu-library/4.0/JuliaCall/julia/setup.jl:168

```

---

<div class="post-metadata">

### Author: ![Non-Contradiction](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-contradiction/32/2208_2.png) [@Non-Contradiction](https://discourse.julialang.org/u/Non-Contradiction)
#### Post date: [May 2, 2021, 4:28am UTC](https://discourse.julialang.org/t/how-to-set-julia-project-for-juliacall/60408/2 "2021-05-02T04:28:19Z")

</div>

I believe this should work, and I just verify that it works on Windows 10.  
And I notice that the environment is created at `"/tmp/testenv"`  
but in the JuliaCall script, the path is `"/tmp/testproj"`. Is this a typo, or is it the actual code?  
One quick thing to check is that JuliaCall has some julia package dependencies like `RCall`, which should be installed into the environment at `"/tmp/testproj"` if JuliaCall “correctly” picks that environment, otherwise JuliaCall won’t be able to finish loading the setup script.

---

<div class="post-metadata">

### Author: ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)
#### Post date: [May 2, 2021, 5:17am UTC](https://discourse.julialang.org/t/how-to-set-julia-project-for-juliacall/60408/3 "2021-05-02T05:17:09Z")

</div>

Thanks, @Non-Contradiction. I’ll fix that typo in the post. It turns out the actual code on which the MWE was based also had another issue involving the package (not DataFrames) being loaded!
