The tuning parameter grid should have columns mtry

I'm trying to use ranger via Caret. Interestingly, it pops out an error message:

Error in train.default(x <- as.matrix(train_data[, !c(excludeVar), with = FALSE]),  : 
  The tuning parameter grid should have columns mtry

So I check:

> model_grid
  mtry splitrule min.node.size
1    5      gini            10

Codes I used:

 mtry <- round(sqrt(ncol(train_data) - 3),0)      # ignore ID fields and target fields

 # parameters
 model_grid <- expand.grid(
   mtry = mtry                                    # mtry specified here
   ,splitrule = "gini"
   ,min.node.size = 10
 )
 model_trcontrol <- trainControl(
   method = "cv",
   number = 2,                                     
   search = "grid",
   verboseIter = FALSE,
   returnData = FALSE,
   savePredictions = "none",          
   classProbs = TRUE,
   summaryFunction = twoClassSummary,
   sampling = "up",                                # over-sampling
   allowParallel = TRUE
 )

 # training
 targetVar = target_fields[i]
 excludeVar = c(ID_fields,targetVar)
 model_train <- train(
   x <- as.matrix(train_data[,!c(excludeVar),with = FALSE]),
   y <- eval(parse(text = paste0("as.factor(train_data$",targetVar,")"))),
   trControl = model_trcontrol,
   tuneGrid = model_grid,
   method = "ranger"
 )

The codes work on my local PC Rstudio (when I used a small sample of data), but not on a virtual machine Rstudio.

Any possible reason why it happens? How to fix it?