There is no function named "pathexpand"

I get this error when running ‘packer build’:

$ packer build .
Error: Call to unknown function

  on externalities.pkr.hcl line 13, in variable "stuff_dir":
  13:   default = pathexpand("~/stuff")

There is no function named "pathexpand".


$ packer console --config-type=hcl2
> pathexpand("~/stuff")
> /Users/me/stuff

This is my variable definition:

variable "stuff_dir" {
  type    = string
  default = pathexpand("~/stuff")

Am I going crazy? If the function doesn’t exist, how come I can call it from the console? Can I only call it in limited circumstances and is the error message wrong?

I have the same problem, except with any function.

I’ve tried with several functions like timestamp() and floor(), but always get the same error message “There is no function named …”. Tried with Packer 1.7.10 and 1.8.5 on Linux and Windows.

However, in Packer Console, the functions work fine as long as I specify the config-type=hcl2 when starting the console.

@ogham did you find out what the problem was?