Not able to Execute Example Script from the Getting Started Guide

#1

Hello everyone. I’m a new user who started with Julia just this week. (Windows 10/Julia 1.1.0) I began by going through the ‘Getting Started’ guide on julialang.org but came across a problem soon. When I try to run the basic script examples I see errors.


C:\Users\Navneeth\code\julia>julia -e 'println(PROGRAM_FILE); for x in ARGS; println(x); end' foo bar
ERROR: syntax: incomplete: invalid character literal

C:\Users\Navneeth\code\julia>echo 'println(PROGRAM_FILE); for x in ARGS; println(x); end' > script.jl

C:\Users\Navneeth\code\julia>julia script.jl foo bar
ERROR: LoadError: syntax: invalid character literal
Stacktrace:
 [1] include at .\boot.jl:326 [inlined]
 [2] include_relative(::Module, ::String) at .\loading.jl:1038
 [3] include(::Module, ::String) at .\sysimg.jl:29
 [4] exec_options(::Base.JLOptions) at .\client.jl:267
 [5] _start() at .\client.jl:436
in expression starting at C:\Users\Navneeth\code\julia\script.jl:1

C:\Users\Navneeth\code\julia>

However when I replace the single quotes ' with double quotes ", the first example works while the second one simply returns to the shell without errors.

C:\Users\Navneeth\code\julia>del script.jl

C:\Users\Navneeth\code\julia>julia -e "println(PROGRAM_FILE); for x in ARGS; println(x); end" foo bar

foo
bar

C:\Users\Navneeth\code\julia>echo "println(PROGRAM_FILE); for x in ARGS; println(x); end" > script.jl

C:\Users\Navneeth\code\julia>julia script.jl foo bar

C:\Users\Navneeth\code\julia>

Can anyone tell me why this is happening? I switched over to the notebooks at Juliabox to learn the basics and found that we cannot use single quotes to define strings. Does this have anything to do with these errors?

0 Likes

#2

If you look at script.jl you can see windows wrote a string with the quotes, so the program does nothing. If you remove the quotes in the console it works though.

I don’t know if there a way to make these examples work on both windows and linux.

1 Like

#3

Thanks. It does solve the problem. Perhaps a word of warning could be inserted for the Windows user.

0 Likes