diff --git a/Dockerfile.alpine b/Dockerfile.alpine
index cf9a8965716370a92b08994beea5c73ce954034c..1a4a47c464b977ecd7e817001f4ccbfcb32204a3 100644
--- a/Dockerfile.alpine
+++ b/Dockerfile.alpine
@@ -25,6 +25,7 @@ RUN apk add --no-cache \
 # see https://opentofu.org/docs/intro/install/standalone
 # We may want to switch to installing manually from GitHub and verifying signature
 ARG OPENTOFU_VERSION
+ENV OPENTOFU_VERSION=${OPENTOFU_VERSION}
 RUN curl --proto '=https' --tlsv1.2 -fsSL https://get.opentofu.org/install-opentofu.sh -o install-opentofu.sh && \
     chmod +x install-opentofu.sh && \
     ./install-opentofu.sh --install-method standalone --opentofu-version "${OPENTOFU_VERSION}" && \
diff --git a/Dockerfile.debian b/Dockerfile.debian
index fa6be25ffcd376754f7f839984c366e0becd179c..4c70d71057b2ddfd12691d7faf891f21ae9ae976 100644
--- a/Dockerfile.debian
+++ b/Dockerfile.debian
@@ -40,6 +40,7 @@ RUN wget https://gitlab.com/gitlab-org/cli/-/releases/v${GLAB_VERSION}/downloads
 # see https://opentofu.org/docs/intro/install/standalone
 # We may want to switch to installing manually from GitHub and verifying signature
 ARG OPENTOFU_VERSION
+ENV OPENTOFU_VERSION=${OPENTOFU_VERSION}
 RUN curl --proto '=https' --tlsv1.2 -fsSL https://get.opentofu.org/install-opentofu.sh -o install-opentofu.sh && \
     chmod +x install-opentofu.sh && \
     ./install-opentofu.sh --install-method standalone --opentofu-version "${OPENTOFU_VERSION}" && \
diff --git a/src/gitlab-tofu.sh b/src/gitlab-tofu.sh
index 3fb85a90c15cbc58fa9427df207f4b3b8a4c239f..7c70dc4e8a5d7649805f3ece53b92f6b511ae121 100644
--- a/src/gitlab-tofu.sh
+++ b/src/gitlab-tofu.sh
@@ -231,6 +231,11 @@ fi
 # Helper functions
 # ================
 
+# is_tofu_at_least checks if OPENTOFU_VERSION is at least the one provided
+is_tofu_at_least() {
+  test "$(printf "%s\n$1" "$OPENTOFU_VERSION" | sort -V | head -1)" = "$1"
+}
+
 # define_http_backend defines the HTTP backend in a file called __gitlab-opentofu-backend.tf if no backend can be found.
 # The backend configuration is attempted to be found with a simple grep.
 define_http_backend() {
@@ -430,6 +435,11 @@ if [ $sourced -eq 0 ]; then
     ;;
     "validate")
       $should_do_implicit_init && tofu_init -backend=false
+
+      if ! is_tofu_at_least "1.8.0"; then
+        var_file_args=""
+      fi
+
       # shellcheck disable=SC2086
       tofu "${tf_chdir_opt}" "${@}" ${var_file_args}
     ;;
@@ -440,6 +450,11 @@ if [ $sourced -eq 0 ]; then
     ;;
     "graph")
       $should_do_implicit_init && tofu_init
+
+      if ! is_tofu_at_least "1.8.0"; then
+        var_file_args=""
+      fi
+
       # shellcheck disable=SC2086
       tofu "${tf_chdir_opt}" "${@}" ${var_file_args}
     ;;
diff --git a/tests/unit/gitlab-tofu.bats b/tests/unit/gitlab-tofu.bats
index dcdc59c6ea3555002c836c21d0ef14905b685d1f..479475de492c322dd3f95898502989aa818fb3dc 100644
--- a/tests/unit/gitlab-tofu.bats
+++ b/tests/unit/gitlab-tofu.bats
@@ -230,3 +230,16 @@ EOF
 
   $SHELL test.sh
 }
+
+@test "is_tofu_at_least helper function" {
+  load $(which gitlab-tofu)
+
+  OPENTOFU_VERSION="1.9.1" run is_tofu_at_least "1.8.0"
+  assert_success
+
+  OPENTOFU_VERSION="1.8.0" run is_tofu_at_least "1.8.0"
+  assert_success
+  
+  OPENTOFU_VERSION="1.6.3" run is_tofu_at_least "1.8.0"
+  assert_failure
+}