internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: conan-io/conan

Issue:
tools.os_info.detect_windows_subsystem() should not raise
To help us debug your issue please explain:

*conanfile.py*
```
...
    def build(self):
      ...
       if tools.os_info.detect_windows_subsystem():
           make = "make"
           use_win_bash = True
```

commnad:
```
$ conan create . danitmb/testing
...
ERROR: TBB/4.4.4@danimtb/testing: Error in build() method, line 42
        if tools.os_info.detect_windows_subsystem():
        ConanException: bash is not in the path
```

Using `cygwin_installer/2.9.0@bincrafters/stable` and `msys2_installer/20161025@bincrafters/stable` bash is in path and `tools.os_info.detect_windows_subsystem()` behaves well.

So it would be better to not raise in case you want to check if you are in a windows subsystem and just return `None`.

- [x] I've read the [CONTRIBUTING guide](https://raw.githubusercontent.com/conan-io/conan/develop/.github/CONTRIBUTING.md).
- [x] I've specified the Conan version, operating system version and any tool that can be relevant: conan 1.2.3
- [x] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.




Discussion:

Resolving patch:
diff --git a/conans/client/tools/oss.py b/conans/client/tools/oss.py
--- a/conans/client/tools/oss.py
+++ b/conans/client/tools/oss.py
@@ -262,7 +262,10 @@ def uname(options=None):
     @staticmethod
     def detect_windows_subsystem():
         from conans.client.tools.win import CYGWIN, MSYS2, MSYS, WSL
-        output = OSInfo.uname()
+        try:
+            output = OSInfo.uname()
+        except ConanException:
+            return None
         if not output:
             return None
         if "cygwin" in output:


Test patch:
diff --git a/conans/test/util/tools_test.py b/conans/test/util/tools_test.py
--- a/conans/test/util/tools_test.py
+++ b/conans/test/util/tools_test.py
@@ -685,3 +685,10 @@ def download_retries_test(self):
         tools.download("https://httpbin.org/basic-auth/user/passwd", dest,
                        headers={"Authorization": "Basic dXNlcjpwYXNzd2Q="}, overwrite=True)
 
+    def detect_windows_subsystem_test(self):
+        # Dont raise test
+        result = tools.os_info.detect_windows_subsystem()
+        if not tools.os_info.bash_path or platform.system() != "Windows":
+            self.assertEqual(None, result)
+        else:
+            self.assertEqual(str, type(result))
Repository: conan-io/conan

Issue:
1.3.0 regression: tools.save doesn't have "append" parameter
For no obvious reason `conans.util.files.save` method was split into 2 methods: `save` and `save_append` with former not having `append` parameter and latter not being exported from `tools`.

Since `tools.save` is in [the documentation](http://docs.conan.io/en/latest/reference/tools.html#tools-save) I consider it as a public API and suggest restore previous behavior.


Discussion:
We will solve and release asap. Probably tomorrow. Thanks for reporting

Resolving patch:
diff --git a/conans/tools.py b/conans/tools.py
--- a/conans/tools.py
+++ b/conans/tools.py
@@ -7,8 +7,25 @@
 # noinspection PyUnresolvedReferences
 from conans.util.env_reader import get_env
 # noinspection PyUnresolvedReferences
-from conans.util.files import (_generic_algorithm_sum, load, save, sha256sum,
-                               sha1sum, md5sum, md5, touch, relative_dirs, rmdir, mkdir)
+from conans.util.files import (_generic_algorithm_sum, load, sha256sum,
+                               sha1sum, md5sum, md5, touch, relative_dirs,
+                               rmdir, mkdir, to_file_bytes)
+
+
+def save(path, content, append=False):
+    """
+    This method is duplicated to the conans.util.files, because the
+    intent is to modify the internally used save() methods for unicode
+    encodings
+    """
+    try:
+        os.makedirs(os.path.dirname(path))
+    except:
+        pass
+
+    mode = "ab" if append else "wb"
+    with open(path, mode) as handle:
+        handle.write(to_file_bytes(content))
 
 
 # Global instances


Test patch:
diff --git a/conans/test/util/conanfile_tools_test.py b/conans/test/util/conanfile_tools_test.py
--- a/conans/test/util/conanfile_tools_test.py
+++ b/conans/test/util/conanfile_tools_test.py
@@ -23,6 +23,21 @@ class ConanFileToolsTest(ConanFile):
 
 class ConanfileToolsTest(unittest.TestCase):
 
+    def save_append_test(self):
+        # https://github.com/conan-io/conan/issues/2841 (regression)
+        client = TestClient()
+        conanfile = """from conans import ConanFile
+from conans.tools import save
+class Pkg(ConanFile):
+    def source(self):
+        save("myfile.txt", "Hello", append=True)
+"""
+        client.save({"conanfile.py": conanfile,
+                     "myfile.txt": "World"})
+        client.run("source .")
+        self.assertEqual("WorldHello",
+                         load(os.path.join(client.current_folder, "myfile.txt")))
+
     def test_untar(self):
         tmp_dir = temp_folder()
         file_path = os.path.join(tmp_dir, "example.txt")
Repository: conan-io/conan

Issue:
Conan does not set define `CMAKE_SYSTEM_VERSION` when "os.api_level" specified



Discussion:
Any solution yet? I've run in the same issue. 
Hi, sorry for not answering this issue, we missed it. You can adjust it by setting `CONAN_CMAKE_SYSTEM_VERSION`. 
You are right, for Android it should be adjusted to the api_level, so we will add this to the 1.4 milestone.

reference: https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html#cross-compiling-for-android


Resolving patch:
diff --git a/conans/client/build/cmake.py b/conans/client/build/cmake.py
--- a/conans/client/build/cmake.py
+++ b/conans/client/build/cmake.py
@@ -53,7 +53,10 @@ def __init__(self, conanfile, generator=None, cmake_system_name=True,
         self._compiler = self._settings.get_safe("compiler")
         self._compiler_version = self._settings.get_safe("compiler.version")
         self._arch = self._settings.get_safe("arch")
-        self._op_system_version = self._settings.get_safe("os.version")
+
+        os_ver_str = "os.api_level" if self._os == "Android" else "os.version"
+        self._op_system_version = self._settings.get_safe(os_ver_str)
+
         self._libcxx = self._settings.get_safe("compiler.libcxx")
         self._runtime = self._settings.get_safe("compiler.runtime")
         self._build_type = self._settings.get_safe("build_type")


Test patch:
diff --git a/conans/test/build_helpers/cmake_test.py b/conans/test/build_helpers/cmake_test.py
--- a/conans/test/build_helpers/cmake_test.py
+++ b/conans/test/build_helpers/cmake_test.py
@@ -773,6 +773,27 @@ def set_toolset_test(self):
         cmake = CMake(conan_file)
         self.assertIn('-T "v140"', cmake.command_line)
 
+    def test_cmake_system_version_android(self):
+        with tools.environment_append({"CONAN_CMAKE_SYSTEM_NAME": "SomeSystem",
+                                       "CONAN_CMAKE_GENERATOR": "SomeGenerator"}):
+            settings = Settings.loads(default_settings_yml)
+            settings.os = "WindowsStore"
+            settings.os.version = "8.1"
+
+            conan_file = ConanFileMock()
+            conan_file.settings = settings
+            cmake = CMake(conan_file)
+            self.assertEquals(cmake.definitions["CMAKE_SYSTEM_VERSION"], "8.1")
+
+            settings = Settings.loads(default_settings_yml)
+            settings.os = "Android"
+            settings.os.api_level = "32"
+
+            conan_file = ConanFileMock()
+            conan_file.settings = settings
+            cmake = CMake(conan_file)
+            self.assertEquals(cmake.definitions["CMAKE_SYSTEM_VERSION"], "32")
+
     @staticmethod
     def scape(args):
         pattern = "%s" if sys.platform == "win32" else r"'%s'"
Repository: conan-io/conan

Issue:
[bug] Error when using default_options as tuple with equals sign (=) in value
To help us debug your issue please explain:

- [x] I've read the [CONTRIBUTING guide](https://raw.githubusercontent.com/conan-io/conan/develop/.github/CONTRIBUTING.md).
- [x] I've specified the Conan version, operating system version and any tool that can be relevant.
- [x] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.

Similar to #1296, specifying a tuple for `default_options` with an option that has an `=` in the value part fails.

```python
from conans import ConanFile

class ReproConan(ConanFile):
    name = "repro"
    version = "0.1.0"
    options = {"opt": "ANY"}
    default_options = ("opt=a=b",)
```

```
$ conan install .
ERROR: /path/to/conanfile.py: Error while initializing options. too many values to unpack (expected 2)
```

This happens on latest on the `develop` branch.


Discussion:

Resolving patch:
diff --git a/conans/model/options.py b/conans/model/options.py
--- a/conans/model/options.py
+++ b/conans/model/options.py
@@ -164,7 +164,7 @@ def __init__(self, values=None):
         if isinstance(values, tuple):
             new_values = []
             for v in values:
-                option, value = v.split("=")
+                option, value = v.split("=", 1)
                 new_values.append((option.strip(), value.strip()))
             values = new_values
 


Test patch:
diff --git a/conans/test/integration/options_caching_test.py b/conans/test/integration/options_test.py
similarity index 94%
rename from conans/test/integration/options_caching_test.py
rename to conans/test/integration/options_test.py
--- a/conans/test/integration/options_caching_test.py
+++ b/conans/test/integration/options_test.py
@@ -5,7 +5,7 @@
 import os
 
 
-class OptionTest(unittest.TestCase):
+class OptionsTest(unittest.TestCase):
 
     def parsing_test(self):
         client = TestClient()
@@ -15,6 +15,7 @@ class EqualerrorConan(ConanFile):
     name = "equal"
     version = "1.0.0"
     options = {"opt": "ANY"}
+    default_options = ("opt=b=c",)
 
     def build(self):
         self.output.warn("OPTION %s" % self.options.opt)
@@ -31,7 +32,7 @@ def build(self):
         client.run("install . --build=missing")
         self.assertIn("OPTION a=b", client.user_io.out)
 
-    def basic_test(self):
+    def basic_caching_test(self):
         client = TestClient()
         zlib = '''
 from conans import ConanFile
Repository: conan-io/conan

Issue:
Version("6") < Version("6.0") == True 
Version model has a bug.
Version("6") is considered lower than "6.0". It introduced a bug (fixed in #2885) with the default`std`.



Discussion:
Following the above logic all these should be ``True``:
- `Version("4") > Version("4.1")`
- `Version("4") > Version("4.0.7")`
- `Version("4") > Version("4.9999.99999")`
- `Version("4.7") > Version("4.1.99999")`
- `Version("4.1.1.1") < Version("4.9999.99999")`
- `Version("4.99999.1.1") > Version("4.9999.99999")`

Resolving patch:
diff --git a/conans/model/version.py b/conans/model/version.py
--- a/conans/model/version.py
+++ b/conans/model/version.py
@@ -98,6 +98,18 @@ def __cmp__(self, other):
         if not isinstance(other, Version):
             other = Version(other)
 
+        # Check equals
+        def get_el(a_list, index):
+            if len(a_list) - 1 < index:
+                return 0  # out of range, 4 == 4.0 == 4.0.0
+            return a_list[index]
+
+        equals = all(get_el(other.as_list, ind) == get_el(self.as_list, ind)
+                     for ind in range(0, max(len(other.as_list), len(self.as_list))))
+        if equals:
+            return 0
+
+        # Check greater than or less than
         other_list = other.as_list
         for ind, el in enumerate(self.as_list):
             if ind + 1 > len(other_list):
@@ -117,8 +129,6 @@ def __cmp__(self, other):
                 return -1
         if len(other_list) > len(self.as_list):
             return -1
-        else:
-            return 0
 
     def __gt__(self, other):
         return self.__cmp__(other) == 1
@@ -131,3 +141,12 @@ def __le__(self, other):
 
     def __ge__(self, other):
         return self.__cmp__(other) in [0, 1]
+
+    def __eq__(self, other):
+        return self.__cmp__(other) == 0
+
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
+    def __hash__(self):
+        return str.__hash__(self)


Test patch:
diff --git a/conans/test/model/version_test.py b/conans/test/model/version_test.py
--- a/conans/test/model/version_test.py
+++ b/conans/test/model/version_test.py
@@ -39,6 +39,19 @@ def simple_test(self):
         self.assertTrue(Version("1.2.1-dev") > Version("1.2.alpha"))
         self.assertTrue(Version("1.2.1-dev") > Version("1.2-alpha"))
 
+        self.assertFalse(Version("4") < Version("4.0.0"))
+        self.assertFalse(Version("4") > Version("4.0.0"))
+        self.assertFalse(Version("4") != Version("4.0.0"))
+        self.assertTrue(Version("4") == Version("4.0.0"))
+        self.assertTrue(Version("4") <= Version("4.0.0"))
+        self.assertTrue(Version("4") >= Version("4.0.0"))
+        self.assertTrue(Version("4.0") == Version("4.0.0"))
+
+        self.assertTrue(Version("4.0.0") == Version("4.0.0"))
+        self.assertTrue(Version("4.0.1") != "4")
+        self.assertFalse(Version("4.0.0.1") == "4")
+        self.assertTrue(Version("4.0.0.1") >= "4")
+
     def text_test(self):
         v1 = Version("master+build2")
         self.assertEqual(v1.major(), "master")
Repository: conan-io/conan

Issue:
Confusing message or behavior in SCM when url can't be deduced
It raises:

```python
if not origin:
            raise ConanException("Repo origin cannot be deduced by 'auto', using source folder")
```

But it doesn't use the source folder, as execution is aborted. Maybe change the message? Or allow to proceed and create the package locally, even if the remote URL is not defined?




Discussion:
I don't think we should proceed, I'm changing the message.

Resolving patch:
diff --git a/conans/client/cmd/export.py b/conans/client/cmd/export.py
--- a/conans/client/cmd/export.py
+++ b/conans/client/cmd/export.py
@@ -112,7 +112,7 @@ def _capture_export_scm_data(conanfile, src_path, destination_folder, output, pa
     if scm.url == "auto":
         origin = scm.get_remote_url()
         if not origin:
-            raise ConanException("Repo origin cannot be deduced by 'auto', using source folder")
+            raise ConanException("Repo origin cannot be deduced by 'auto'")
         output.success("Repo origin deduced by 'auto': %s" % origin)
         scm.url = origin
     if scm.revision == "auto":


Test patch:
diff --git a/conans/test/functional/scm_test.py b/conans/test/functional/scm_test.py
--- a/conans/test/functional/scm_test.py
+++ b/conans/test/functional/scm_test.py
@@ -40,6 +40,31 @@ def _commit_contents(self):
         self.client.runner("git add .", cwd=self.client.current_folder)
         self.client.runner('git commit -m  "commiting"', cwd=self.client.current_folder)
 
+    def test_repeat_clone_changing_subfolder(self):
+        tmp = '''
+from conans import ConanFile, tools
+
+class ConanLib(ConanFile):
+    name = "lib"
+    version = "0.1"
+    scm = {{
+        "type": "git",
+        "url": "{url}",
+        "revision": "{revision}",
+        "subfolder": "onesubfolder"
+    }}
+'''
+        path, commit = create_local_git_repo({"myfile": "contents"}, branch="my_release")
+        conanfile = tmp.format(url=path, revision=commit)
+        self.client.save({"conanfile.py": conanfile,
+                          "myfile.txt": "My file is copied"})
+        self.client.run("create . user/channel")
+        conanfile = conanfile.replace('"onesubfolder"', '"othersubfolder"')
+        self.client.save({"conanfile.py": conanfile})
+        self.client.run("create . user/channel")
+        folder = self.client.client_cache.source(ConanFileReference.loads("lib/0.1@user/channel"))
+        self.assertIn("othersubfolder", os.listdir(folder))
+
     def test_auto_git(self):
         curdir = self.client.current_folder.replace("\\", "/")
         conanfile = base.format(directory="None", url="auto", revision="auto")
@@ -47,7 +72,7 @@ def test_auto_git(self):
         self._commit_contents()
         error = self.client.run("export . user/channel", ignore_error=True)
         self.assertTrue(error)
-        self.assertIn("Repo origin cannot be deduced by 'auto', using source folder",
+        self.assertIn("Repo origin cannot be deduced by 'auto'",
                       self.client.out)
 
         self.client.runner('git remote add origin https://myrepo.com.git', cwd=curdir)
Repository: conan-io/conan

Issue:
cppstd in settings.yml was not updated when upgrading to 1.4
I've just upgraded to Conan 1.4 and `settings.yml.new` has this:

    cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17]

I expected to see `20` and `gnu20` there.


Discussion:
Yes. It is a bug. Thanks for reporting. Will solve it  in 1.4.1

Resolving patch:
diff --git a/conans/client/conf/__init__.py b/conans/client/conf/__init__.py
--- a/conans/client/conf/__init__.py
+++ b/conans/client/conf/__init__.py
@@ -70,7 +70,7 @@
         libcxx: [libstdc++, libc++]
 
 build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel]
-cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17]
+cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20]
 """
 
 default_client_conf = """
diff --git a/conans/client/migrations.py b/conans/client/migrations.py
--- a/conans/client/migrations.py
+++ b/conans/client/migrations.py
@@ -98,7 +98,7 @@ def _make_migrations(self, old_version):
         version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0", "9.1"]
         libcxx: [libstdc++, libc++]
 build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel]
-cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20]
+cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17]
 """
             self._update_settings_yml(old_settings)
 


Test patch:
Repository: conan-io/conan

Issue:
The specified 'cppstd=20' is not available for 'gcc 8'.
Using Conan 1.4.0, I've manually added `20` and `gnu20` to `cppstd` in `settings.yml`. But when trying to build a package I get:

    ERROR: The specified 'cppstd=20' is not available for 'gcc 8'. Possible values are ['98', 'gnu98', '11', 'gnu11', '14', 'gnu14', '17', 'gnu17']'


Discussion:

Resolving patch:
diff --git a/conans/client/build/cppstd_flags.py b/conans/client/build/cppstd_flags.py
--- a/conans/client/build/cppstd_flags.py
+++ b/conans/client/build/cppstd_flags.py
@@ -3,7 +3,7 @@
 
 def available_cppstd_versions(compiler, compiler_version):
     ret = []
-    stds = ["98", "gnu98", "11", "gnu11", "14",  "gnu14", "17", "gnu17"]
+    stds = ["98", "gnu98", "11", "gnu11", "14",  "gnu14", "17", "gnu17", "20", "gnu20"]
     for stdver in stds:
         if cppstd_flag(compiler, compiler_version, stdver):
             ret.append(stdver)


Test patch:
diff --git a/conans/test/integration/cppstd_test.py b/conans/test/integration/cppstd_test.py
--- a/conans/test/integration/cppstd_test.py
+++ b/conans/test/integration/cppstd_test.py
@@ -28,6 +28,22 @@ class TestConan(ConanFile):
         client.run('create . user/testing -s compiler="gcc" -s compiler.libcxx="libstdc++11" '
                    '-s compiler.version="6.3" -s cppstd=17')
 
+    def gcc_8_std_20_test(self):
+        client = TestClient()
+
+        conanfile = """from conans import ConanFile
+
+class TestConan(ConanFile):
+    name = "MyLib"
+    version = "0.1"
+    settings = "compiler", "cppstd"
+
+"""
+        client.save({CONANFILE: conanfile})
+        client.run('create . user/testing -s compiler="gcc" '
+                   '-s compiler.libcxx="libstdc++11" '
+                   '-s compiler.version="8" -s cppstd=20')
+
     def set_default_package_id_test(self):
         client = TestClient()
         conanfile = """from conans import ConanFile
Repository: conan-io/conan

Issue:
cmake project generator incorrect order
`project(PackageTest CXX)
cmake_minimum_required(VERSION 2.8.12)`

test package cmake projects get generated in this order. 

the order should be  

`cmake_minimum_required(VERSION 2.8.12)
project(PackageTest CXX)`

see cmake documentation :
https://cmake.org/cmake/help/v3.6/command/cmake_minimum_required.html

> Call the cmake_minimum_required() command at the beginning of the top-level CMakeLists.txt file even before calling the project() command. It is important to establish version and policy settings before invoking other commands whose behavior they may affect.




Discussion:

Resolving patch:
diff --git a/conans/client/cmd/new.py b/conans/client/cmd/new.py
--- a/conans/client/cmd/new.py
+++ b/conans/client/cmd/new.py
@@ -162,8 +162,8 @@ def test(self):
             self.run(".%sexample" % os.sep)
 """
 
-test_cmake = """project(PackageTest CXX)
-cmake_minimum_required(VERSION 2.8.12)
+test_cmake = """cmake_minimum_required(VERSION 2.8.12)
+project(PackageTest CXX)
 
 include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
 conan_basic_setup()
@@ -209,8 +209,8 @@ def test(self):
 }
 """
 
-cmake = """project(MyHello CXX)
-cmake_minimum_required(VERSION 2.8)
+cmake = """cmake_minimum_required(VERSION 2.8)
+project(MyHello CXX)
 
 include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
 conan_basic_setup()


Test patch:
Repository: conan-io/conan

Issue:
Improve error message on wrong value for settings attribute
I had a wrong value for the settings attribute like:
```
settings = {"os_build": 'Linux', "arch_build": ["x86", "x86_64"]}
```
And the error message was very strange:
```
ERROR: /home/users/.../export/conanfile.py: Error while initializing settings. Invalid setting 'L' is not a valid 'os_build' value.
Possible values are ['FreeBSD', 'Linux', 'Macos', 'SunOS', 'Windows', 'WindowsStore']
```
It's not obvious at this point, what the problem was. After quite some digging, I found that the value for os_build is supposed to be a list.
Maybe apply some schema checking at this point for a better error message.


Discussion:
Hi, yes, I think some type check could be done here. Thanks for reporting.

Resolving patch:
diff --git a/conans/model/settings.py b/conans/model/settings.py
--- a/conans/model/settings.py
+++ b/conans/model/settings.py
@@ -345,6 +345,8 @@ def constraint(self, constraint_def, raise_undefined_field=True):
             other_field_def = constraint_def[field]
             if other_field_def is None:  # Means leave it as is
                 continue
+            if isinstance(other_field_def, str):
+                other_field_def = [other_field_def]
 
             values_to_remove = []
             for value in config_item.values_range:  # value = "Visual Studio"


Test patch:
diff --git a/conans/test/model/other_settings_test.py b/conans/test/model/other_settings_test.py
--- a/conans/test/model/other_settings_test.py
+++ b/conans/test/model/other_settings_test.py
@@ -131,6 +131,19 @@ def build(self):
         self.assertIn("build_type", load(client.paths.settings_path))
         self.assertIn("390146894f59dda18c902ee25e649ef590140732", client.user_io.out)
 
+    def settings_constraint_error_type_test(self):
+        # https://github.com/conan-io/conan/issues/3022
+        conanfile = """from conans import ConanFile
+class Test(ConanFile):
+    settings = {"os": "Linux"}
+    def build(self):
+        self.output.info("OS!!: %s" % self.settings.os)
+    """
+        client = TestClient()
+        client.save({"conanfile.py": conanfile})
+        client.run("create . Pkg/0.1@user/testing -s os=Linux")
+        self.assertIn("Pkg/0.1@user/testing: OS!!: Linux", client.out)
+
     def settings_constraint_test(self):
         conanfile = """from conans import ConanFile
 class Test(ConanFile):