How do I redirect stdin to interactive Julia?

I need to run a Pkg command on several remote boxen. I wrote a file like this:

]
dev ../Foo/ ../Bar/ ../Baz/ ../Quux/

and ran julia --project -i </path/to/file in the project directory. Julia responded:

ERROR: ParseError:
# Error @ none:1:1
]
╙ ── unexpected `]`
Stacktrace:
 [1] top-level scope
   @ none:1

If I run julia --project -i and then type ], I get a pkg> prompt and can run dev. How do I get Julia to run an interactive session with input from a file instead of the keyboard?

I believe ] is only recognized when you directly type it in REPL (Pasting "]" into the Julia REPL is inconsistent across platforms · Issue #58041 · JuliaLang/julia · GitHub).

You can use Pkg this way instead:

using Pkg
Pkg.develop(path="../Foo")
Pkg.develop(path="../Bar")
Pkg.develop(path="../Baz")

which can be called from the CLI:

julia --project -e 'using Pkg; Pkg.develop(path="../Foo"); Pkg.develop(path="../Bar"); Pkg.develop(path="../Baz");'

I know that

dev ../Foo/
dev ../Bar/

doesn’t work, because of dependencies. Can I call Pkg.develop with multiple arguments?

Pkg.develop([Pkg.PackageSpec(path="../Foo"), 
             Pkg.PackageSpec(path="../Bar"),
             Pkg.PackageSpec(path="../Baz")])

Not sure if there’s a more convenient interface.

1 Like

you can also do pkg"dev ..."

I think I’ll try that, but if not I’ll just do it by hand. There are only 12 boxen, and I don’t think I’ll have to do it more than once for each.