I'm trying to fit a lasso regression to some simulated data. The outcome variable is called 'loss' and is drawn from a gamma distribution. I can successfully fit a model when I hard code the penalty parameter but when I try to tune it as per the reproducible example below I get the following error:

"Error in class(): 0 arguments passed to 'class' which requires 1"

```
library(tidymodels)
library(dplyr)
# make up data
df <- tibble(loss = rgamma(10000, 1, scale = 14),
predictor1 = runif(10000),
predictor2 = runif(10000))
# create bootstraps
df_boots <- bootstraps(df)
# set up workflow
wf <- workflow() %>%
add_formula(loss ~ .) %>%
add_model(linear_reg(penalty = tune(), mixture = 1) %>%
set_engine("glmnet", family = Gamma))
# tune
tune_model <- tune_grid(
wf,
resamples = df_boots,
grid = grid_regular(penalty(), levels = 50)
)
#> Warning: package 'rlang' was built under R version 3.6.3
#>
#> Attaching package: 'rlang'
#> The following objects are masked from 'package:purrr':
#>
#> %@%, as_function, flatten, flatten_chr, flatten_dbl, flatten_int,
#> flatten_lgl, flatten_raw, invoke, list_along, modify, prepend,
#> splice
#> Warning: package 'vctrs' was built under R version 3.6.3
#>
#> Attaching package: 'vctrs'
#> The following object is masked from 'package:tibble':
#>
#> data_frame
#> The following object is masked from 'package:dplyr':
#>
#> data_frame
#> Warning: package 'glmnet' was built under R version 3.6.3
#> Loading required package: Matrix
#>
#> Attaching package: 'Matrix'
#> The following objects are masked from 'package:tidyr':
#>
#> expand, pack, unpack
#> Loaded glmnet 4.0-2
#> x Bootstrap01: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap02: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap03: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap04: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap05: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap06: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap07: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap08: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap09: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap10: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap11: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap12: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap13: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap14: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap15: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap16: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap17: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap18: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap19: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap20: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap21: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap22: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap23: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap24: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> x Bootstrap25: preprocessor 1/1, model 1/1 (predictions): Error in class(): 0 arguments...
#> Warning: All models failed. See the `.notes` column.
```

^{Created on 2021-02-15 by the reprex package (v1.0.0)}