Why ``julia -e`` does not work on Windows?

C:\Users\joaqu\zzz>julia -e "using Pkg; Pkg.activate(".")"
ERROR: syntax: invalid identifier name "."
 [1] top-level scope

but no problem on Linux

j@Marilu:~/aaa$ julia -e 'using Pkg; Pkg.activate(".");'
  Activating new project at `~/aaa`

Since you use the same quotes both around and inside the string in this case it looks like your shell interprets this as executing the code using Pkg; Pkg.activate(.). You would get the same error trying that exact code in Bash too. Perhaps you can escape the inner quotes as \", or use single quotes just like in the Bash example (I don’t have access to a Cmd shell so can not test).

1 Like

Thanks, That is it.
I had tried all variations I could think of for julia -e \"...\", julia -e ' ...', ``julia -e ` …``` but missed the obvious solution.

Strange that this has not shown up yet (that I remember or could find with search)

There was a related question recently:

That’s not entirely related: the problem here was that the code was quoted incorrectly.

For reference, the bit of code I posted is part of a GH action to build a Franklin site and I was trying to make it work from Windows.

I’m pretty sure that syntax is wrong also in bash and all other Unix shells I know.