Invalid version string
See original GitHub issueGetting 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:
- Created a year ago
- Reactions:12
- Comments:5 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fix works here are as well.
New release would be nice because
setuptools-rust
is used bypipenv
at build time (so hot-patching not trivial).Running into the same problem on Solaris/Illumos/SmartOS.
For reference,
rustc -V
output isand
rustc -Vv
output is: