Error: Unbound value String.ends_with

I’m trying to do the Tour of OCaml. And have stucked with functions.
I try in utop:

utop # String.ends_with;;
Error: Unbound value String.ends_with

But accordingly to the Tour it should be

# String.ends_with;;
- : suffix:string -> string -> bool = <fun>

How fix this error?

I think you have an implicit open Base somewhere. If it is true, then Stdlib.String.ends_with should work

What is your OCaml version ? opam switch should say.
String.ends_with is only available since version 4.13.
Version 4.14.1 or 5.1.1 should be good choices currently.

1 Like


utop # Stdlib.String.ends_with;;
Error: Unbound value Stdlib.String.ends_with
user@pad ~> opam switch                                                               17:44
#  switch   compiler             description
→  default  ocaml-system.4.08.1  default

You have an outdated version of OCaml, try upgrading to one of the new versions mentioned above.

I did

opam switch create 4.14.1 
opam switch remove default
opam install ocaml-lsp-server odoc ocamlformat utop 


utop # String.ends_with;;
- : suffix:string -> string -> bool = <fun>

Thank you everyone!


I installed core and core_bench based on Real World OCaml

Somehow, when core core_bench is installed together with ocaml-lsp-server odoc ocamlformat utop will trigger the same error inside utop.