-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find workspace version in crate_package #23
Comments
This issue can be fixed with the following patch. diff --git a/src/lib.rs b/src/lib.rs
index 8f28131..2f1735d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -371,9 +371,15 @@ impl Manifest {
Error::InvalidManifest("[package] section is missing `version`".to_string())
})?;
- let package_version = package_version_value.as_str().ok_or_else(|| {
- Error::InvalidManifest("`version` in [package] section is not a string".to_string())
- })?;
+ let package_version = match package_version_value {
+ Value::String(s) => s.clone(),
+ Value::Table(t) => "*".to_string(),
+ _ => {
+ return Err(Error::InvalidManifest(
+ "`version` in [package] section is not a string".to_string(),
+ ))
+ }
+ };
let package = Package {
key: package_key.to_string(),
|
I think the correct approach is to return the version defined in the |
Yeah, we need a stable way to get the workspace root. |
Could |
CARGO_PKG_VERSION is the version of the current package, not dependency. |
Given this limitation, it may actually be a reasonable compromise to return |
I tested it and found that it only helps with this issue when using the proc macro like cargo-i18n ... |
If it's about the current package version and not the dependency version, that could indeed still work well in some cases. |
Wait, why did we have crate_package in the first place? Did cc @kellpossible (because you opened #11) |
I'm proposing at cargo-i18n to fallback to |
In the case of |
When I use cargo workspace, version is pulled from the crate's cargo.toml instead of workspace cargo.toml, resulting in a bug.
It should work with this cargo.toml :
[package]
name = "my_package"
version.workspace = true
authors.workspace = true
edition.workspace = true
lib.rs line 359: pub fn crate_package(&self) -> Result
This lib is used by i18n_embed which causes the impossibility to use it in a workspace.
The text was updated successfully, but these errors were encountered: