Error message 'extra tokens after end of expression'

This may be a silly question, I’m totally new to Julia.

I’m working in the terminal (on a Mac):
julia> VERSION
v"1.11.2"

This command ‘VERSION’ works fine, as well as some other commands.
But I keep receiving the same error message with many expressions, even when I copy-paste them. For example:

julia> juliaup update

ERROR: ParseError:

Error @ REPL[7]:1:8

juliaup update

└───┘ ── extra tokens after end of expression

Stacktrace:
[1] top-level scope
@ none:1

I would expect julia to give the comment that this is the latest version (or something like that), but not an error about ‘extra tokens’.

There are no spaces behind the expression (here or with any of the others). All I do is press ENTER.

An expression like 3+8 works fine; it returns 11 as it should.
I’m not quite sure why that works (just as VERSION) but many other commands do not.

I tried uninstalling julia completely by deleting the folder ‘julia’ (in order to do a fresh install), but this didn’t work: in the terminal I can still start up julia (still after restarting the computer). And I still get the same error message.
I do not see julia in my Mac applications folder, so I can’t uninstall there.

Any advice on how to resolve this? Many thanks!

First of all, welcome!

julia> VERSION
v"1.11.2"

VERSION is a variable within the Julia environment rather than a command. When writing the name of a variable in the REPL its current value (if it has one) will be printed. When within the Julia REPL (as signified by the julia> prompt) you need to work with Julia functions which are called with parentheses. juliaup on the other hand, is a program that you need to call from your system prompt. Either call it from a different terminal not running Julia or quit Julia by pressing CTRL + D before running it.

Julia REPL examples:

julia> typeof(VERSION) # call the 'typeof'function
VersionNumber # VERSION is of type 'VersionNumber'

julia> println("Hello") # Print the string 'Hello'
Hello

# 'x' is not defined
julia> x 
ERROR: UndefVarError: `x` not defined in `Main`
Suggestion: check for spelling errors or missing imports.

# Bind the value '3'  to the variable 'x'
julia> x = 3
3

# Calling 'x' now shows its value
julia> x 
3

# Call the 'sqrt' function on x to calculate its square root
julia> sqrt(x) 
1.7320508075688772

# Define a new function adding 1 to a number
julia> function add1(number) 
           number + 1
       end
add1 (generic function with 1 method)

# It adds 1
julia> add1(x)
4

I would suggest having a look at the “getting started” section of the documentation: Getting Started · The Julia Language as well as some other resources: Get started with Julia

2 Likes

Thank you! Yes, juliaup did run from the system prompt.
I will certainly look at the 'getting started 'material.

Kind regards,
and thanks again, Mar