Can't use clipboard() out REPL

Hey guys!

I’m having problems using clipboard() outside of the REPL…

If i make a clip.jl file with:

x = “hi”
clipboard(x)

I get the message:
ERROR LoadError: UndefVarError: clipboard not defined

Also with only
clipboard()

What am i doing wrong?

Inside REPL, it works fine…

Thanks!

Hi, welcome to the Julia Discourse forum! If you do @which clipboard, it shows that clipboard is defined in the InteractiveUtils module. It appears that this module is automatically loaded by the REPL but not when executing a script. So just adding using InteractiveUtils: clipboard at the start of your script should fix it.

I can’t find anything about this in the documentation, maybe worth investigating and fixing with a PR…

2 Likes

Thanks a lot!
It worked!

1 Like