Setup an environment from a shell script

I’m hoping to run some simulations from a shell script. The structure is something like:

  \__ Manifest.toml
  \__ Project.toml
    \__ env.jl
    \__ simulate.jl

where contains

julia simulate.jl

simulate.jl contains

println(" running simulations...")

and env.jl contains

using Pkg

to pull from Manifest/Project files I have in parent/. However, when I run $ ./, I get the following error:

ERROR: LoadError: ArgumentError: Module Pkg not found in current path.
Run `Pkg.add("Pkg")` to install the Pkg package.
 [1] _require(::Symbol) at ./loading.jl:428
 [2] require(::Symbol) at ./loading.jl:398
 [3] include_from_node1(::String) at ./loading.jl:569
 [4] include(::String) at ./sysimg.jl:14
 [5] process_options(::Base.JLOptions) at ./client.jl:305
 [6] _start() at ./client.jl:371

Am I doing something wrong??

Here’s my version info:

Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)

Ah, I just need to call julia from $JULIA_BINDIR/julia in the shell script and make sure the shebang references the current environment #!/usr/bin/env sh

@jacob_roth It is very worthwhile documenting this. You are running the simulation in a batch system such as Slurm or PBS? There are differences between interactive and non-interactive login shells.
I think you have come across a situation where the non-interactive shell is different.

I don’t need to see the output, which might contain proprietary information. Howwer could you submit a script which simply runs the env command and similary run env at the terminal, then do a diff of the results?

Of course, I may be wrong here.

@johnh: I think I was just using the “wrong” version of Julia. My default path wasn’t properly set up :slight_smile: