question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid version string

See original GitHub issue

Getting Rust version produces incorrect result:

  File "/dist/pkg/lib/python3.10/site-packages/setuptools_rust/rustc_info.py", line 13, in get_rust_version
    return Version(_rust_version_verbose().split(" ")[1])
  File "/dist/pkg/lib/python3.10/site-packages/semantic_version/base.py", line 105, in __init__
    major, minor, patch, prerelease, build = self.parse(version_string, partial)
  File "/dist/pkg/lib/python3.10/site-packages/semantic_version/base.py", line 318, in parse
    raise ValueError('Invalid version string: %r' % version_string)
ValueError: Invalid version string: '1.62.0\nbinary:'

That’s because the output of rustc -Vv is being split by a single space (" "), and the new-line character stays.

I had to fix it with this patch:

--- setuptools_rust/rustc_info.py.orig	2022-07-05 06:20:44.000000000 +0000
+++ setuptools_rust/rustc_info.py
@@ -10,7 +10,7 @@ def get_rust_version() -> Optional[Versi
     try:
         # first line of rustc -Vv is something like
         # rustc 1.61.0 (fe5b13d68 2022-05-18)
-        return Version(_rust_version_verbose().split(" ")[1])
+        return Version(_rust_version().split(" ")[1])
     except (subprocess.CalledProcessError, OSError):
         return None
 
@@ -59,5 +59,10 @@ def get_rust_target_list() -> List[str]:
 
 
 @lru_cache()
+def _rust_version() -> str:
+    return subprocess.check_output(["rustc", "-V"], text=True)
+
+
+@lru_cache()
 def _rust_version_verbose() -> str:
     return subprocess.check_output(["rustc", "-Vv"], text=True)

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:12
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
ostefanocommented, Jul 5, 2022

Fix works here are as well.

New release would be nice because setuptools-rust is used by pipenv at build time (so hot-patching not trivial).

1reaction
gaigecommented, Jul 5, 2022

Running into the same problem on Solaris/Illumos/SmartOS.

For reference, rustc -V output is

rustc 1.60.0

and rustc -Vv output is:

rustc 1.60.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-illumos
release: 1.60.0
LLVM version: 13.0.1
Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not parse version constraint : Invalid version string
Hello, i get the following error. its equal what i do (composer.phar update / diagnose ...) [UnexpectedValueException] Could not parse ...
Read more >
composer could not load package Invalid version string
I use docker-compose and install bundle inside in image. docker-copose and other docker file with all dependecies absolutelty the same, all in ...
Read more >
Composer "Could not parse version constraint {version}" error
Invalid version string "{version}' the last module version doesn't contain {version} on the composer.json file.
Read more >
Could not parse version constraint discuss - Flarum Community
I get the following error: In VersionParser.php line 521: Could not parse version constraint discuss: Invalid version string "forum" require ...
Read more >
I got composer install error under php 7.4 - Laracasts
Invalid version string "~4.*" In VersionParser.php line 485: Could not parse version constraint ~4.*: Invalid version string "~4.*". In composer.json:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found