Repository: conan-io/conan

Issue:
GCC ABI compatibility warning always points to default profile
Steps to reproduce:

```
$ conan --version  # not the latest, but the issue is still present in master
Conan version 1.12.1
$ conan profile new --detect gcc
Found gcc 8.2
gcc>=5, using the major as version
Found clang 7.0

************************* WARNING: GCC OLD ABI COMPATIBILITY ***********************
 
Conan detected a GCC version > 5 but has adjusted the 'compiler.libcxx' setting to
'libstdc++' for backwards compatibility.
Your compiler is likely using the new CXX11 ABI by default (libstdc++11).

If you want Conan to use the new ABI, edit the default profile at:

    ~/.conan/profiles/default

adjusting 'compiler.libcxx=libstdc++11'

************************************************************************************
```

This is misleading, because I did not create a `default` profile, but rather a profile named `gcc`.

I suppose the warning in [this line](https://github.com/conan-io/conan/blob/dac7447838d95361676c43cb055e202556092be6/conans/client/conf/detect.py#L151) and two lines up should be changed to use the actual name of the profile being created.

Perhaps a bit of an edge case because most folks will use only one profile, but still.


Discussion:

Resolving patch:
diff --git a/conans/client/cache/cache.py b/conans/client/cache/cache.py
--- a/conans/client/cache/cache.py
+++ b/conans/client/cache/cache.py
@@ -191,7 +191,7 @@ def default_profile(self):
                                  "default profile (%s)" % self.default_profile_path,
                                  Color.BRIGHT_YELLOW)
 
-            default_settings = detect_defaults_settings(self._output)
+            default_settings = detect_defaults_settings(self._output, profile_path=self.default_profile_path)
             self._output.writeln("Default settings", Color.BRIGHT_YELLOW)
             self._output.writeln("\n".join(["\t%s=%s" % (k, v) for (k, v) in default_settings]),
                                  Color.BRIGHT_YELLOW)
diff --git a/conans/client/cmd/profile.py b/conans/client/cmd/profile.py
--- a/conans/client/cmd/profile.py
+++ b/conans/client/cmd/profile.py
@@ -43,7 +43,7 @@ def cmd_profile_create(profile_name, cache_profiles_path, output, detect=False):
 
     profile = Profile()
     if detect:
-        settings = detect_defaults_settings(output)
+        settings = detect_defaults_settings(output, profile_path)
         for name, value in settings:
             profile.settings[name] = value
 
diff --git a/conans/client/conf/detect.py b/conans/client/conf/detect.py
--- a/conans/client/conf/detect.py
+++ b/conans/client/conf/detect.py
@@ -125,7 +125,7 @@ def _get_default_compiler(output):
         return gcc or clang
 
 
-def _detect_compiler_version(result, output):
+def _detect_compiler_version(result, output, profile_path):
     try:
         compiler, version = _get_default_compiler(output)
     except:
@@ -140,18 +140,18 @@ def _detect_compiler_version(result, output):
         elif compiler == "gcc":
             result.append(("compiler.libcxx", "libstdc++"))
             if Version(version) >= Version("5.1"):
-
+                profile_name = os.path.basename(profile_path)
                 msg = """
 Conan detected a GCC version > 5 but has adjusted the 'compiler.libcxx' setting to
 'libstdc++' for backwards compatibility.
 Your compiler is likely using the new CXX11 ABI by default (libstdc++11).
 
-If you want Conan to use the new ABI, edit the default profile at:
+If you want Conan to use the new ABI, edit the {profile} profile at:
 
-    ~/.conan/profiles/default
+    {profile_path}
 
 adjusting 'compiler.libcxx=libstdc++11'
-"""
+""".format(profile=profile_name, profile_path=profile_path)
                 output.writeln("\n************************* WARNING: GCC OLD ABI COMPATIBILITY "
                                "***********************\n %s\n************************************"
                                "************************************************\n\n\n" % msg,
@@ -193,12 +193,15 @@ def _detect_os_arch(result, output):
         result.append(("arch_build", arch))
 
 
-def detect_defaults_settings(output):
+def detect_defaults_settings(output, profile_path):
     """ try to deduce current machine values without any constraints at all
+    :param output: Conan Output instance
+    :param profile_path: Conan profile file path
+    :return: A list with default settings
     """
     result = []
     _detect_os_arch(result, output)
-    _detect_compiler_version(result, output)
+    _detect_compiler_version(result, output, profile_path)
     result.append(("build_type", "Release"))
 
     return result


Test patch:
diff --git a/conans/test/functional/command/profile_test.py b/conans/test/functional/command/profile_test.py
--- a/conans/test/functional/command/profile_test.py
+++ b/conans/test/functional/command/profile_test.py
@@ -12,6 +12,11 @@ class ProfileTest(unittest.TestCase):
     def reuse_output_test(self):
         client = TestClient()
         client.run("profile new myprofile --detect")
+
+        if "WARNING: GCC OLD ABI COMPATIBILITY" in client.out:
+            self.assertIn("edit the myprofile profile at", client.out)
+            self.assertIn("profiles/myprofile", client.out)
+
         client.run("profile update options.Pkg:myoption=123 myprofile")
         client.run("profile update env.Pkg2:myenv=123 myprofile")
         client.run("profile show myprofile")
@@ -69,6 +74,10 @@ def show_test(self):
     def profile_update_and_get_test(self):
         client = TestClient()
         client.run("profile new ./MyProfile --detect")
+        if "WARNING: GCC OLD ABI COMPATIBILITY" in client.out:
+            self.assertIn("edit the MyProfile profile at", client.out)
+            self.assertIn(os.path.join(client.current_folder, "MyProfile"), client.out)
+
         pr_path = os.path.join(client.current_folder, "MyProfile")
 
         client.run("profile update settings.os=FakeOS ./MyProfile")
diff --git a/conans/test/integration/conf_default_settings_test.py b/conans/test/integration/conf_default_settings_test.py
--- a/conans/test/integration/conf_default_settings_test.py
+++ b/conans/test/integration/conf_default_settings_test.py
@@ -53,7 +53,7 @@ def env_setting_override_test(self):
         out = MockOut()
         cache = ClientCache(tmp_dir, None, out)
 
-        base_settings = OrderedDict(detect_defaults_settings(out))
+        base_settings = OrderedDict(detect_defaults_settings(out, profile_path="~/.conan/profiles/default"))
 
         with tools.environment_append({"CONAN_ENV_COMPILER_VERSION": "4.6"}):
             expected = copy.copy(base_settings)
diff --git a/conans/test/unittests/util/detect_test.py b/conans/test/unittests/util/detect_test.py
--- a/conans/test/unittests/util/detect_test.py
+++ b/conans/test/unittests/util/detect_test.py
@@ -1,3 +1,4 @@
+import os
 import platform
 import subprocess
 import unittest
@@ -6,6 +7,7 @@
 
 from conans.client import tools
 from conans.client.conf.detect import detect_defaults_settings
+from conans.paths import DEFAULT_PROFILE_NAME
 from conans.test.utils.tools import TestBufferConanOutput
 
 
@@ -18,7 +20,7 @@ def detect_default_compilers_test(self):
             "Windows": "Visual Studio"
         }
         output = TestBufferConanOutput()
-        result = detect_defaults_settings(output)
+        result = detect_defaults_settings(output, profile_path=DEFAULT_PROFILE_NAME)
         # result is a list of tuples (name, value) so converting it to dict
         result = dict(result)
         platform_compiler = platform_default_compilers.get(platform.system(), None)
@@ -46,7 +48,7 @@ def detect_default_in_mac_os_using_gcc_as_default_test(self):
 
         output = TestBufferConanOutput()
         with tools.environment_append({"CC": "gcc"}):
-            result = detect_defaults_settings(output)
+            result = detect_defaults_settings(output, profile_path=DEFAULT_PROFILE_NAME)
         # result is a list of tuples (name, value) so converting it to dict
         result = dict(result)
         # No compiler should be detected
@@ -56,7 +58,39 @@ def detect_default_in_mac_os_using_gcc_as_default_test(self):
 
     @mock.patch("platform.machine", return_value="")
     def test_detect_empty_arch(self, _):
-        result = detect_defaults_settings(output=TestBufferConanOutput())
+        result = detect_defaults_settings(output=TestBufferConanOutput(), profile_path=DEFAULT_PROFILE_NAME)
         result = dict(result)
         self.assertTrue("arch" not in result)
         self.assertTrue("arch_build" not in result)
+
+    @mock.patch("conans.client.conf.detect._gcc_compiler", return_value=("gcc", "8"))
+    def detect_custom_profile_test(self, _):
+        output = TestBufferConanOutput()
+        with tools.environment_append({"CC": "gcc"}):
+            detect_defaults_settings(output, profile_path="~/.conan/profiles/mycustomprofile")
+            self.assertIn("edit the mycustomprofile profile at", output)
+            self.assertIn("~/.conan/profiles/mycustomprofile", output)
+
+    @mock.patch("conans.client.conf.detect._gcc_compiler", return_value=("gcc", "8"))
+    def detect_default_profile_test(self, _):
+        output = TestBufferConanOutput()
+        with tools.environment_append({"CC": "gcc"}):
+            detect_defaults_settings(output, profile_path="~/.conan/profiles/default")
+            self.assertIn("edit the default profile at", output)
+            self.assertIn("~/.conan/profiles/default", output)
+
+    @mock.patch("conans.client.conf.detect._gcc_compiler", return_value=("gcc", "8"))
+    def detect_file_profile_test(self, _):
+        output = TestBufferConanOutput()
+        with tools.environment_append({"CC": "gcc"}):
+            detect_defaults_settings(output, profile_path="./MyProfile")
+            self.assertIn("edit the MyProfile profile at", output)
+            self.assertIn("./MyProfile", output)
+
+    @mock.patch("conans.client.conf.detect._gcc_compiler", return_value=("gcc", "8"))
+    def detect_abs_file_profile_test(self, _):
+        output = TestBufferConanOutput()
+        with tools.environment_append({"CC": "gcc"}):
+            detect_defaults_settings(output, profile_path="/foo/bar/quz/custom-profile")
+            self.assertIn("edit the custom-profile profile at", output)
+            self.assertIn("/foo/bar/quz/custom-profile", output)