docx-rs icon indicating copy to clipboard operation
docx-rs copied to clipboard

Error Compiling dependency `jetscii`

Open mmogib opened this issue 3 years ago • 9 comments
trafficstars

When I added docx = 1.1.2 to my project, the following error appears

   Compiling jetscii v0.4.4
error: generic parameters may not be used in const operations
   --> C:\Users\mmogi\.cargo\registry\src\github.com-1ecc6299db9ec823\jetscii-0.4.4\src\simd.rs:109:13
    |
109 |             T::CONTROL_BYTE,
    |             ^^^^^^^^^^^^^^^ cannot perform const operation using `T`
    |
    = note: type parameters may not be used in const expressions

error: generic parameters may not be used in const operations
   --> C:\Users\mmogi\.cargo\registry\src\github.com-1ecc6299db9ec823\jetscii-0.4.4\src\simd.rs:148:13
    |
148 |             T::CONTROL_BYTE,
    |             ^^^^^^^^^^^^^^^ cannot perform const operation using `T`
    |
    = note: type parameters may not be used in const expressions

error: could not compile `jetscii` due to 2 previous errors

When I remove docx= 1.1.2, my project compiles with no error. docx depends on jetscii which seems to be the source of the error.

FYI: rustc 1.61.0 (fe5b13d68 2022-05-18)

mmogib avatar Aug 15 '22 05:08 mmogib

I'm having the same issue,i suspect that upgrading jetscii to the newest version should fix it ,but im not too sure how to override the jetscii version in this crate

poipiii avatar Aug 18 '22 05:08 poipiii

In that case, patch section in cargo should help.

fMeow avatar Aug 18 '22 10:08 fMeow

So how would I go about doing this? I am new to rust and the link wasn't very clear on what to do.

IvoryCoding avatar Sep 01 '22 22:09 IvoryCoding

Put this in your Cargo.toml should do.

[patch.crates-io]
jetscii = "0.5.3"

fMeow avatar Sep 02 '22 01:09 fMeow

That gave me this error:

Execution failed (exit code 101). C:/Users/Emma/.cargo/bin/cargo.exe metadata --verbose --format-version 1 --all-features stdout : Updating crates.io index error: failed to resolve patches for https://github.com/rust-lang/crates.io-index`

Caused by: patch for jetscii in https://github.com/rust-lang/crates.io-index points to the same source, but patches must point to different sources

stderr : `

instead of crates-io should I put the link for docx or strong-xml? Or is something else wrong?

IvoryCoding avatar Sep 02 '22 02:09 IvoryCoding

I find myself successfully compiling the docx using rust 1.63.0 on stable channel.

Please try upgrade your cargo (rustup udpate) and update your dependencies (cargo update). If the issue still persist, please create an mvp repo and I will take a look.

fMeow avatar Sep 02 '22 05:09 fMeow

It is still persisting so I shall get on that. I updated rust and cargo. I should have a repo of it already but I will do another with it for ya there

IvoryCoding avatar Sep 08 '22 15:09 IvoryCoding

I can confirm this is still broken on 1.63.0. I suspect updating to a newer version of jetscii might be required, and this release should probably get yanked.

@fMeow I have a suspicion that compilation success depends on the target machine, not on the compiler version. It's hard to create a mvp for that, as we can't give you our computers.

It literally breaks if you add docx = 1.1.2 to a default cargo new hello-world project.

It also breaks if you only add jetscii = "0.4.4", but it works again if you add jetscii = "0.5.0". Therefore I'd argue that upgrading jetscii to 0.5.x would fix the problem.

Finomnis avatar Sep 14 '22 20:09 Finomnis

I figured out it was due to a major change in the strong-xml dependency. All I did was assume that CDATA doesn't exist in these files (passing false to writer.write_flatten_text) and yeah.

If you want to immediately try out my changes, please add the following to your cargo dependency:

[patch.crates-io]
docx = { git = "https://github.com/dsgallups/docx-rs"}

I attempted a PR for this issue. No guarantees of its stability. However, I don't believe docx uses CDATA in their XML.

Edit: I've found a (relatively) maintained fork of this repo. This is most likely a better alternative than my fix.

dsgallups avatar Jan 30 '23 22:01 dsgallups