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

Issue:
Autodetected arch is empty, producing wrong default profile
If platform.machine() returns empty (can do it in some cases, as when called from cmake), the arch is empty, leading to a:

```
arch=
```

In the default profile, which later can result in an error because "" is not a known architecture in settings.yml. It seems that not adding the ``arch=`` in the profile could be the way to go.




Discussion:

Resolving patch:
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
@@ -185,17 +185,19 @@ def _detect_os_arch(result, output):
     the_os = detected_os()
     result.append(("os", the_os))
     result.append(("os_build", the_os))
-    arch = architectures.get(platform.machine().lower(), platform.machine().lower())
-    if arch.startswith('arm'):
-        for a in ("armv6", "armv7hf", "armv7", "armv8"):
-            if arch.startswith(a):
-                arch = a
-                break
-        else:
-            output.error("Your ARM '%s' architecture is probably not defined in settings.yml\n"
-                         "Please check your conan.conf and settings.yml files" % arch)
-    result.append(("arch", arch))
-    result.append(("arch_build", arch))
+    platform_machine = platform.machine().lower()
+    if platform_machine:
+        arch = architectures.get(platform_machine, platform_machine)
+        if arch.startswith('arm'):
+            for a in ("armv6", "armv7hf", "armv7", "armv8"):
+                if arch.startswith(a):
+                    arch = a
+                    break
+            else:
+                output.error("Your ARM '%s' architecture is probably not defined in settings.yml\n"
+                             "Please check your conan.conf and settings.yml files" % arch)
+        result.append(("arch", arch))
+        result.append(("arch_build", arch))
 
 
 def detect_defaults_settings(output):


Test patch:
diff --git a/conans/test/util/detect_test.py b/conans/test/util/detect_test.py
--- a/conans/test/util/detect_test.py
+++ b/conans/test/util/detect_test.py
@@ -1,6 +1,7 @@
 import platform
 import subprocess
 import unittest
+from mock import mock
 
 from conans import tools
 from conans.client.conf.detect import detect_defaults_settings
@@ -51,3 +52,10 @@ def detect_default_in_mac_os_using_gcc_as_default_test(self):
         self.assertIsNone(result.get("compiler", None))
         self.assertIn("gcc detected as a frontend using apple-clang", output)
         self.assertIsNotNone(output.error)
+
+    @mock.patch("platform.machine", return_value="")
+    def test_detect_empty_arch(self, _):
+        result = detect_defaults_settings(output=TestBufferConanOutput())
+        result = dict(result)
+        self.assertTrue("arch" not in result)
+        self.assertTrue("arch_build" not in result)
Repository: conan-io/conan

Issue:
Update allowed gcc version in settings to 8.2
The current stable version of GCC is 8.2.




Discussion:

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
@@ -55,7 +55,7 @@
                   "5", "5.1", "5.2", "5.3", "5.4", "5.5",
                   "6", "6.1", "6.2", "6.3", "6.4",
                   "7", "7.1", "7.2", "7.3",
-                  "8", "8.1"]
+                  "8", "8.1", "8.2"]
         libcxx: [libstdc++, libstdc++11]
         threads: [None, posix, win32] #  Windows MinGW
         exception: [None, dwarf2, sjlj, seh] # Windows MinGW


Test patch:
Repository: conan-io/conan

Issue:
Deploy Conan develop branch on test.pypi.org
To help us debug your issue please explain:

Hi!

My proposal here is return to use test.pypi.org (used until Conan 0.4.1) when merging a new PR into develop branch. I see no difficult installing Conan on my machine running `pip install .` but for who wants to install the latest version (non-stable) without git, it could be an good option.

For example, bincrafters-package-tools is uploaded to test.pypi.org for every new change in master branch (we follow github flow), only tags are uploaded to pypi.org. That flow helped me to find many bugs, including missing files in the package.

The version released could be incremental, using the suffix dev as well.

Conan Version: ANY
OS: ANY

- [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.




Discussion:
I like very much this idea, and it could help a lot to close the loop easier with feedback from users.
Is this possible @lasote ? What would be the complexity?
Hi, yes, I like it too. The complexity is not high, just automate it in jenkins for the develop branch, but a couple things need to be done, and you know, the CI stuff takes time:

1. Mechanism to bump the dev version in our  `__init__.py` file
2. Jenkins job tune: pypi credentials (managed as secret credentials in Jenkins) and deploy when develop


Resolving patch:
diff --git a/.ci/bump_dev_version.py b/.ci/bump_dev_version.py
new file mode 100644
--- /dev/null
+++ b/.ci/bump_dev_version.py
@@ -0,0 +1,22 @@
+import os
+import time
+
+
+def replace_in_file(file_path, search, replace):
+    with open(file_path, "r") as handle:
+        content = handle.read()
+        if search not in content:
+            raise Exception("Incorrect development version in conans/__init__.py")
+    content = content.replace(search, replace)
+    content = content.encode("utf-8")
+    with open(file_path, "wb") as handle:
+        handle.write(content)
+
+def bump_dev():
+    vfile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "conans/__init__.py")
+    snapshot = "%s" % int(time.time())
+    replace_in_file(vfile, "-dev'", "-dev%s'" % snapshot)
+
+
+if __name__ == "__main__":
+    bump_dev()


Test patch:
Repository: conan-io/conan

Issue:
"conan install" fails in the root folder
The conan install command seems to fail if I am at the root folder (conan 1.9.1, Win7, x64, NTFS, the user is member of the local Administrators group).
I don't really understand this because when I am somewhere else, and not in the root folder, then conan will properly download and place the package to my "home" or "profile" folder, as expected.
So why does it try to write to the "current folder"?
![grafik](https://user-images.githubusercontent.com/10893838/49015570-c3a23f00-f183-11e8-97a4-09a8094884c5.png)


I gave it a try under Mac (10.13.6, conan 1.8.4) and I have a failure but with a different error code:
![grafik](https://user-images.githubusercontent.com/10893838/49015644-0b28cb00-f184-11e8-9e5d-2b5c0173b05d.png)

I think it is strange ... please consider some more error handling.

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.




Discussion:
Bug confirmed in windows at `c:\`
Thanks for reporting.

Resolving patch:
diff --git a/conans/util/files.py b/conans/util/files.py
--- a/conans/util/files.py
+++ b/conans/util/files.py
@@ -229,11 +229,9 @@ def rmdir(path):
 
 def mkdir(path):
     """Recursive mkdir, doesnt fail if already existing"""
-    try:
-        os.makedirs(path)
-    except OSError as err:
-        if err.errno != EEXIST:
-            raise
+    if os.path.exists(path):
+        return
+    os.makedirs(path)
 
 
 def path_exists(path, basedir):


Test patch:
Repository: conan-io/conan

Issue:
b2 generator does not define projects as rooted
b2 generator's docs mention, that projects for dependencies are defined rooted, so if you have in your recipe
```ini
[requires]
clara/[>0]@bincrafters/stable
```
Then the jam-file created by generator will define a project `/clara`. But it seems, only relative projects
are created, so, instead of `/clara//libs` one has to use `clara//libs`or `../clara//libs` in a subproject.

This can be reproduced by a project like this:
```ini
; conanfile.txt
[requires]
clara/[>0]@bincrafters/stable

[generators]
b2
```

```jam
# jamroot.jam
exe main1 : main.cpp clara//libs ;
exe main2 : main.cpp /clara//libs ;
```
```cpp
int main() {}
```

And building with
```shell
$ conan install . --build missing
$ b2
```
Target `main2` will fail to be built, while target `main1` should be built successfully.

I tested it on Conan 1.11.1. The b2 generator requires Boost.Build >= 1.68

- [x] I've read the [CONTRIBUTING guide](https://github.com/conan-io/conan/blob/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.


Discussion:

Resolving patch:
diff --git a/conans/client/generators/b2.py b/conans/client/generators/b2.py
--- a/conans/client/generators/b2.py
+++ b/conans/client/generators/b2.py
@@ -329,6 +329,10 @@ def b2_toolset_version(self):
         : constant-if call-in-project
         : $(id-mod)
         : constant-if call-in-project ;
+    if [ project.is-jamroot-module $(base-project-mod) ]
+    {
+        use-project /$(id) : $(id) ;
+    }
     return $(id-mod) ;
 }
 


Test patch:
diff --git a/conans/test/unittests/client/generators/b2_test.py b/conans/test/unittests/client/generators/b2_test.py
--- a/conans/test/unittests/client/generators/b2_test.py
+++ b/conans/test/unittests/client/generators/b2_test.py
@@ -81,6 +81,10 @@ def b2_test(self):
         : constant-if call-in-project
         : $(id-mod)
         : constant-if call-in-project ;
+    if [ project.is-jamroot-module $(base-project-mod) ]
+    {
+        use-project /$(id) : $(id) ;
+    }
     return $(id-mod) ;
 }
Repository: conan-io/conan

Issue:
conan config install and "LICENSE.txt" and "README.md"
To help us debug your issue please explain:

- [x ] I've read the [CONTRIBUTING guide](https://github.com/conan-io/conan/blob/develop/.github/CONTRIBUTING.md).
- [ ] 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.

If you install the conan config via **conan config install ....** like 
(conan config install https://github.com/bincrafters/conan-config.git)

All files will be copied in the ~/.conan folder. So far so good, but files like the famous "LICENSE.txt" and "README.md" are also copied to ~/.conan. This somehow pollutes the .conan folder. I think its better to filter out this special files during the installation.



Discussion:

Resolving patch:
diff --git a/conans/client/conf/config_installer.py b/conans/client/conf/config_installer.py
--- a/conans/client/conf/config_installer.py
+++ b/conans/client/conf/config_installer.py
@@ -83,6 +83,10 @@ def _process_folder(folder, cache, output):
             elif f == "remotes.txt":
                 output.info("Defining remotes from remotes.txt")
                 _handle_remotes(cache, os.path.join(root, f))
+            elif f == "README.md":
+                output.info("Skip README.md")
+            elif f == "LICENSE.txt":
+                output.info("Skip LICENSE.txt")
             else:
                 relpath = os.path.relpath(root, folder)
                 target_folder = os.path.join(cache.conan_folder, relpath)


Test patch:
Repository: conan-io/conan

Issue:
provide CONAN_CACHE_NO_LOCKS environment variable
right now debugging conan (e.g. via PyCharm) is not very convenient, as stopping debugging causes strayed lock files, and it's necessary to run `conan remove --locks` each time before running.
there is config setting `general.no_cache_locks`, but it's global, and affects regular conan execution.
with environment variable, it's much more straightforward, as it can be easily specified in debugging target properties.

To help us debug your issue please explain:

- [x] I've read the [CONTRIBUTING guide](https://github.com/conan-io/conan/blob/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.




Discussion:

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
@@ -98,7 +98,7 @@
 # recipe_linter = False               # environment CONAN_RECIPE_LINTER
 # read_only_cache = True              # environment CONAN_READ_ONLY_CACHE
 # pylintrc = path/to/pylintrc_file    # environment CONAN_PYLINTRC
-# cache_no_locks = True               # Disable locking mechanism of local cache
+# cache_no_locks = True               # environment CONAN_CACHE_NO_LOCKS
 # user_home_short = your_path         # environment CONAN_USER_HOME_SHORT
 # use_always_short_paths = False      # environment CONAN_USE_ALWAYS_SHORT_PATHS
 # skip_vs_projects_upgrade = False    # environment CONAN_SKIP_VS_PROJECTS_UPGRADE
@@ -168,6 +168,7 @@ def env_vars(self):
                "CONAN_COMPRESSION_LEVEL": self._env_c("general.compression_level", "CONAN_COMPRESSION_LEVEL", "9"),
                "CONAN_NON_INTERACTIVE": self._env_c("general.non_interactive", "CONAN_NON_INTERACTIVE", "False"),
                "CONAN_PYLINTRC": self._env_c("general.pylintrc", "CONAN_PYLINTRC", None),
+               "CONAN_CACHE_NO_LOCKS": self._env_c("general.cache_no_locks", "CONAN_CACHE_NO_LOCKS", "False"),
                "CONAN_PYLINT_WERR": self._env_c("general.pylint_werr", "CONAN_PYLINT_WERR", None),
                "CONAN_SYSREQUIRES_SUDO": self._env_c("general.sysrequires_sudo", "CONAN_SYSREQUIRES_SUDO", "False"),
                "CONAN_SYSREQUIRES_MODE": self._env_c("general.sysrequires_mode", "CONAN_SYSREQUIRES_MODE", "enabled"),
@@ -315,7 +316,7 @@ def default_profile(self):
     @property
     def cache_no_locks(self):
         try:
-            return self.get_item("general.cache_no_locks")
+            return get_env("CONAN_CACHE_NO_LOCKS", False)
         except ConanException:
             return False
 


Test patch:
Repository: conan-io/conan

Issue:
some uname versions have no -o option
seems like some uname versions have no `-o` option (`--operating-system` print the operating system)
as result conan may fail with the following error:
```
uname: invalid option -- o
Try `uname --help' for more information.
libiconv/1.15@bincrafters/testing:
libiconv/1.15@bincrafters/testing: ERROR: Package 'cf3d83762512009f4f39f4fadd784bb0336ac88c' build failed
libiconv/1.15@bincrafters/testing: WARN: Build folder C:\.conan\ro66ntb6\1
ERROR: libiconv/1.15@bincrafters/testing: Error in build() method, line 105
        if tools.os_info.detect_windows_subsystem() not in ("cygwin", "msys2"):
        AttributeError: 'NoneType' object has no attribute 'startswith'
```

- posix doesn't define `-o`: http://pubs.opengroup.org/onlinepubs/009695399/utilities/uname.html
- while GNU/Linux has it: https://linux.die.net/man/1/uname
- Solaris doesn't: https://docs.oracle.com/cd/E18752_01/html/816-5165/uname-1.html
- QNX doesn't: http://www.qnx.com/developers/docs/6.5.0SP1.update/com.qnx.doc.neutrino_utilities/u/uname.html
- OpenBSD doesn't: https://man.openbsd.org/uname.1
- IRIX doesn't: http://nixdoc.net/man-pages/IRIX/uname.1.html
- AIX doesn't: https://www.ibm.com/support/knowledgecenter/8408-E8E/p8hcg/p8hcg_uname.htm
- HPUX doesn't: http://nixdoc.net/man-pages/hp-ux/man1/uname.1.html

therefore, `-o` appears to be GNU extention
we use `uname(-or)` just to query OS version, so I believe it's safe to change it to just `uname(-r)`

(found during debugging in QNX shell on Windows)

To help us debug your issue please explain:

- [x] I've read the [CONTRIBUTING guide](https://github.com/conan-io/conan/blob/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.




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
@@ -291,7 +291,7 @@ def detect_windows_subsystem():
         if "cygwin" in output:
             return CYGWIN
         elif "msys" in output or "mingw" in output:
-            output = OSInfo.uname("-or")
+            output = OSInfo.uname("-r")
             if output.startswith("2"):
                 return MSYS2
             elif output.startswith("1"):


Test patch:
Repository: conan-io/conan

Issue:
tools.environment_append raises if tries to unset variable which was never set
after #4224, I may use the following code, for instance, to ensure variable is not set:
```
with environment_append({'CONAN_BASH_PATH': None}):
    pass
```
however, it raises if `CONAN_BASH_PATH` is not set (prior to the environment_append invocation):
```
Traceback (most recent call last):
  File "C:\bincrafters\conan\conans\test\unittests\client\tools\os_info\osinfo_test.py", line 39, in test_windows
    with environment_append(new_env):
  File "c:\users\sse4\appdata\local\programs\python\python36\lib\contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "C:\bincrafters\conan\conans\client\tools\env.py", line 57, in environment_append
    os.environ.pop(var)
  File "c:\users\sse4\appdata\local\programs\python\python36\lib\_collections_abc.py", line 795, in pop
    value = self[key]
  File "c:\users\sse4\appdata\local\programs\python\python36\lib\os.py", line 669, in __getitem__
    raise KeyError(key) from None
KeyError: 'CONAN_BASH_PATH'
```
I would expect `tools.environment_append` to be no op in such case, otherwise, it requires additional logic to workaround this behavior.

To help us debug your issue please explain:

- [ ] I've read the [CONTRIBUTING guide](https://github.com/conan-io/conan/blob/develop/.github/CONTRIBUTING.md).
- [ ] I've specified the Conan version, operating system version and any tool that can be relevant.
- [ ] 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/env.py b/conans/client/tools/env.py
--- a/conans/client/tools/env.py
+++ b/conans/client/tools/env.py
@@ -54,7 +54,7 @@ def environment_append(env_vars):
         old_env = dict(os.environ)
         os.environ.update(env_vars)
         for var in unset_vars:
-            os.environ.pop(var)
+            os.environ.pop(var, None)
         try:
             yield
         finally:


Test patch:
diff --git a/conans/test/unittests/client/tools/test_env.py b/conans/test/unittests/client/tools/test_env.py
--- a/conans/test/unittests/client/tools/test_env.py
+++ b/conans/test/unittests/client/tools/test_env.py
@@ -46,3 +46,9 @@ def test_environment_append_unsetting_all_variables(self):
                               'env_var2': 'value2'}),\
              env.environment_append({'env_var1': None}):
                 self.assertNotIn('env_var1', os.environ)
+
+    def test_environment_append_unsetting_non_existing_variables(self):
+        with mock.patch.dict('os.environ',
+                             {'env_var2': 'value2'}),\
+             env.environment_append({'env_var1': None}):
+                self.assertNotIn('env_var1', os.environ)
Repository: conan-io/conan

Issue:
Unexpected behaviour for 'env_reader.get_env'
Behaviour for `env_reader.get_env` ([link](https://github.com/conan-io/conan/blob/e018e0ff0e7f6addf76cf589f471edc23569939d/conans/util/env_reader.py#L12)):

```python
def get_env(env_key, default=None, environment=None):

    if environment is None:
        environment = os.environ

    env_var = environment.get(env_key, default)
    if env_var != default:
        if isinstance(default, str):
            ...
        elif isinstance(default, list):
            return [var.strip() for var in env_var.split(",")]
    return env_var
```

From my point of view the following is unexpected:

```bash
>>> from conans.util.env_reader import get_env
>>> env = {'CONAN_HOOKS': ''}
>>> get_env('CONAN_HOOKS', default=list(), environment=env)
['']
```

IMO, it should return an empty list.

----

I found this making some trials with hooks, once you deactivate all the hooks you have a `conan.conf` file with an empty section:

```ini
[hooks]

```

and then, when executing any command, it gives me the following warning: `WARN: Hook '.py' not found in /Users/jgsogo/.conan/hooks folder. Please remove hook from conan.conf or include it inside the hooks folder.`

So, if you don't consider the previous behavior as unexpected, then an additional check should be added to the `HookManager` to avoid the warning.

cc/ @conan-io/barbarians 


Discussion:
Sure, it should be an empty list.
agree
me too!

Resolving patch:
diff --git a/conans/util/env_reader.py b/conans/util/env_reader.py
--- a/conans/util/env_reader.py
+++ b/conans/util/env_reader.py
@@ -25,5 +25,7 @@ def get_env(env_key, default=None, environment=None):
         elif isinstance(default, float):
             return float(env_var)
         elif isinstance(default, list):
-            return [var.strip() for var in env_var.split(",")]
+            if env_var.strip():
+                return [var.strip() for var in env_var.split(",")]
+            return []
     return env_var


Test patch:
diff --git a/conans/test/unittests/util/env_reader.py b/conans/test/unittests/util/env_reader.py
new file mode 100644
--- /dev/null
+++ b/conans/test/unittests/util/env_reader.py
@@ -0,0 +1,28 @@
+# coding=utf-8
+
+import unittest
+from unittest import mock
+
+from conans.util.env_reader import get_env
+
+
+class GetEnvTest(unittest.TestCase):
+    environment = {"EMPTY_LIST": "",
+                   "LIST": "a,b,c,d"}
+
+    def test_environment(self):
+        """ Ensure that we are using os.environment if no argument is passed """
+        with mock.patch("os.environ.get", return_value="zzz"):
+            a = get_env("whatever", default=None)
+        self.assertEqual(a, "zzz")
+
+    def test_list_empty(self):
+        r = get_env("EMPTY_LIST", default=list(), environment=self.environment)
+        self.assertEqual(r, [])
+
+        r = get_env("NON-EXISTING-LIST", default=list(), environment=self.environment)
+        self.assertEqual(r, [])
+
+    def test_list(self):
+        r = get_env("LIST", default=list(), environment=self.environment)
+        self.assertEqual(r, ["a", "b", "c", "d"])