From 97bcb670551742f3b892b6592e2fa594a091cd88 Mon Sep 17 00:00:00 2001 From: Cam Saul <1455846+camsaul@users.noreply.github.com> Date: Tue, 17 Aug 2021 20:52:49 -0700 Subject: [PATCH] Warn if .lein-env is present on launch (dev-only) (#17477) * Help avoid the .lein-env gotchas * Learn to spell @camsaul * Revert the .gitignore change -- too D A N G E R O U S * Fix version numbers (thanks @jeff303) --- src/metabase/config.clj | 16 ++++++++++++++++ test/metabase/api/session_test.clj | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/metabase/config.clj b/src/metabase/config.clj index fa279434100..d8e2eae2325 100644 --- a/src/metabase/config.clj +++ b/src/metabase/config.clj @@ -1,6 +1,7 @@ (ns metabase.config (:require [clojure.java.io :as io] [clojure.string :as str] + [clojure.tools.logging :as log] [environ.core :as environ] [metabase.plugins.classloader :as classloader]) (:import clojure.lang.Keyword @@ -127,3 +128,18 @@ (def ^Keyword mb-session-cookie-samesite "Value for session cookie's `SameSite` directive. Must be one of \"none\", \"lax\", or \"strict\" (case insensitive)." (mb-session-cookie-samesite*)) + +;; In 0.41.0 we switched from Leiningen to deps.edn. This warning here to keep people from being bitten in the ass by +;; the little gotcha described below. +;; +;; TODO -- after we've shipped 0.43.0, remove this warning. At that point, the last three shipped major releases will +;; all be deps.edn based. +(when (and (not is-prod?) + (.exists (io/file ".lein-env"))) + ;; don't need to i18n since this is a dev-only warning. + (log/warn + (str "Found .lein-env in the project root directory.\n" + "This file was previously created automatically by the Leiningen lein-env plugin.\n" + "Environ will use values from it in preference to env var or Java system properties you've specified.\n" + "You should delete it; it will be recreated as needed when switching to a branch still using Leiningen.\n" + "See https://github.com/metabase/metabase/wiki/Migrating-from-Leiningen-to-tools.deps#custom-env-var-values for more details."))) diff --git a/test/metabase/api/session_test.clj b/test/metabase/api/session_test.clj index 5c6195691ed..e90d8a87d52 100644 --- a/test/metabase/api/session_test.clj +++ b/test/metabase/api/session_test.clj @@ -154,9 +154,9 @@ :body json/parse-string (get-in ["errors" "username"])))] - (is (re= #"^Too many attempts! You must wait 1\d seconds before trying again\.$" + (is (re= #"^Too many attempts! You must wait \d+ seconds before trying again\.$" (error))) - (is (re= #"^Too many attempts! You must wait 4\d seconds before trying again\.$" + (is (re= #"^Too many attempts! You must wait \d+ seconds before trying again\.$" (error))))))) (deftest failure-threshold-per-request-source -- GitLab