LoadError: syntax: "\" is not a unary operator

I get the error LoadError: syntax: "" is not a unary operator every time I try to run Julia from the terminal by typing ‘julia’. The file that doesn’t load is a startup file that says hello every time I run Julia.

ERROR: LoadError: syntax: "" is not a unary operator

Stacktrace:

[1] top-level scope

@ ~/.julia/config/startup.jl:1

in expression starting at /Users/alanwoo/.julia/config/startup.jl:1

I’m new to Julia and a complete newbie to programming so any help would be appreciated!

Looks pretty clearly like you have a syntax error in what you’ve wrote in the file. You should post it so that we know what caused the error.

2 Likes
println("Greetings! 你好! 안녕하세요?")

Works fine for me:

julia> println("Greetings! 你好! 안녕하세요?")
Greetings! 你好! 안녕하세요?

Possibly you are saving it a file using something other than the UTF-8 encoding that Julia requires. What code editor are you using?

PS. Please quote your code in posts: PSA: how to quote code with backticks

1 Like

I’m using TextEdit on Mac which saves the file as .rtf, but I change it to .jl afterwards. Is this a TextEdit issue?

Apologies, I’ll make sure to quote my code next time.

That is likely the issue. RTF files are not regular text files, but also contain formatting instructions. You need to save your code as a raw text file.

1 Like

Thank you! I tried Sublime and it worked!

Yes, you definitely want a programming-oriented editor for code, and one that knows about your programming language. A lot of people working with Julia use vscode with the Julia plugin as a GUI editor.

2 Likes

Thank you so much, I will definitely start using those!