ReadOnlyMemory Error in VS Code

I’m on a MacBook Air (M1, 2020).

If I run the following code in VS Code, I get an error ("ERROR: LoadError: ReadOnlyMemoryError()).

But if I run it in a standalone REPL opened in a terminal, I don’t get the error.

Any pointers on how I can begin to debug and understand this?

using Surrogates
f = x -> exp(x)*x^2+x^3
lb = 0.0
ub = 10.0
x = sample(100,lb,ub,UniformSample())
y = f.(x)
p = 1.9
my_krig = Kriging(x,y,lb,ub,p=p)