Conan: scm Attribute fails to clone tag

Created on 6 Aug 2019  Â·  4Comments  Â·  Source: conan-io/conan

Since conan 1.18.0 the scm attribute is broken for Git tags. Setting revision to a branch – eg. master – still works, but tags fail.

The following recipe (excerpt) worked up to conan 1.17.0 but fails since 1.18.0:

class RestclientcppConan(ConanFile):+
    name = "restclient-cpp"
    version = "0.5.1"
    _source_dir = "{}-{}".format(name, version)
    scm = {
        "type": "git",
        "subfolder": _source_dir,
        "url": "https://github.com/mrtazz/restclient-cpp.git",
        "revision": "0.5.1"
    }

_(The full example recipe is available here.)_

Building locally as well as via Travis CI / Conan Build Tools Container fail with this error:

ERROR: Command 'git -c http.sslVerify=false checkout "0.5.1"' returned non-zero exit status 1.
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
error: pathspec '0.5.1' did not match any file(s) known to git

It turned out that branches still work. Removing the scm attribute and putting the scm part into source() works too.

_Note:_ There's a source() method in all that cases to apply patches.

Broken: scm with tag

scm = {
    ...
    "revision": "0.5.1" # Tag, broken
}

Fails with the error mentioned above

Working: scm with branch

scm = {
    ...
    "revision": "master" # Branch, ok
}

Builds without an error.

Working: source() with tag

# scm part removed
def source(self):
     git = tools.Git(folder=self._source_dir)
     git.clone("https://github.com/mrtazz/restclient-cpp.git", "0.5.1") # Tag, ok

Builds without an error too – even though a tag is used.

Reproduce

  1. Install Conan 1.18.0
  2. Ensure there's no conan data from previous builds
  3. Conan Recipe with scm attribute and git tag as mentioned (ready to use example
  4. Build package: conan create . restclient-cpp/0.5.1
  5. Build fails with git error

Stacktrace

_(From a failed Travis CI build)_

Traceback (most recent call last):
  File "/opt/pyenv/versions/3.7.1/lib/python3.7/site-packages/conans/client/source.py", line 182, in _run_source
    _run_scm(conanfile, src_folder, local_sources_path, output, cache=cache)
  File "/opt/pyenv/versions/3.7.1/lib/python3.7/site-packages/conans/client/source.py", line 243, in _run_scm
    scm.checkout()
  File "/opt/pyenv/versions/3.7.1/lib/python3.7/site-packages/conans/model/scm.py", line 99, in checkout
    submodule=self._data.submodule)
  File "/opt/pyenv/versions/3.7.1/lib/python3.7/site-packages/conans/client/tools/scm.py", line 149, in checkout
    output = self.run('checkout "%s"' % element)
  File "/opt/pyenv/versions/3.7.1/lib/python3.7/site-packages/conans/client/tools/scm.py", line 100, in run
    return super(Git, self).run(command)
  File "/opt/pyenv/versions/3.7.1/lib/python3.7/site-packages/conans/client/tools/scm.py", line 66, in run
    return check_output(command).strip()
  File "/opt/pyenv/versions/3.7.1/lib/python3.7/site-packages/conans/client/tools/oss.py", line 507, in check_output
    raise CalledProcessErrorWithStderr(process.returncode, cmd, output=stderr)
conans.errors.CalledProcessErrorWithStderr: Command 'git -c http.sslVerify=false checkout "0.5.1"' returned non-zero exit status 1.
error: pathspec '0.5.1' did not match any file(s) known to git.

System:

  • Compiler: GCC 4.9 - 9.1 and Clang 3.9 - 8.0
  • Conan: 1.17.0 (ok), 1.18.0 (affected)
  • Python: 3.7
  • OS: Linux and Travis CI with Conan Build Tools Docker Container
low medium critical bug

Most helpful comment

Thanks, I can confirm the issue has been fixed.

All 4 comments

Thanks very much @offa for reporting this. We have already prepared a fix for it, and it will soon be released in 1.18.1.

Great, thanks! :tada:

Conan 1.18.1 has been released with the fix for this issue! https://github.com/conan-io/conan/releases/tag/1.18.1
Thanks

Thanks, I can confirm the issue has been fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

niosHD picture niosHD  Â·  3Comments

zlalanne picture zlalanne  Â·  3Comments

db4 picture db4  Â·  3Comments

niosHD picture niosHD  Â·  3Comments

tonka3000 picture tonka3000  Â·  3Comments