anordal / shellharden

The corrective bash syntax highlighter
Mozilla Public License 2.0
4.62k stars 129 forks source link

Unable to install v4.3.0 via cargo: "or-patterns syntax is experimental" #52

Closed rbairwell closed 2 years ago

rbairwell commented 2 years ago

Hi,

I've just tried installing this on my Docker Debian Bullseye container using cargo and get the following results: (specifically, I'm using the "debian:bullseye-slim" container with a few additional packages - such as coreutils, make, gcc, curl, rustc and cargo)

> cargo install shellharden --verbose
    Updating crates.io index
  Installing shellharden v4.3.0
   Compiling shellharden v4.3.0
     Running `rustc --crate-name shellharden /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/shellharden-4.3.0/src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -Cembed-bitcode=no -C metadata=c67ba048abc62b54 -C extra-filename=-c67ba048abc62b54 --out-dir /tmp/cargo-installie2YhN/release/deps -L dependency=/tmp/cargo-installie2YhN/release/deps --cap-lints allow`
error[E0658]: or-patterns syntax is experimental
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/shellharden-4.3.0/src/sitvarbrace.rs:63:6
   |
63 |                 (State::Name | State::Index | State::Normal, b'}') => {
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
error: failed to compile `shellharden v4.3.0`, intermediate artifacts can be found at `/tmp/cargo-installie2YhN`

Caused by:
  could not compile `shellharden`.

Caused by:
  process didn't exit successfully: `rustc --crate-name shellharden /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/shellharden-4.3.0/src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -Cembed-bitcode=no -C metadata=c67ba048abc62b54 -C extra-filename=-c67ba048abc62b54 --out-dir /tmp/cargo-installie2YhN/release/deps -L dependency=/tmp/cargo-installie2YhN/release/deps --cap-lints allow` (exit code: 1)

Here's some platform information which might help:

> cargo --version
cargo 1.46.0
> rustc --version
rustc 1.48.0
> cat /etc/debian_version
11.3

I've not really run a Rust script before which has failed with an error during install, so I'm not sure what information you may want/need.

anordal commented 2 years ago

Shellharden does not use experimental features. So when rustc thinks so, it's a sign that it's outdated.

Indeed, or-patterns were stabilized in rustc 1.53.0: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1530-2021-06-17

If you can, I suggest to update rustc. I checked that it builds with rustc 1.53.0.

I don't test old compilers. Should I? My assumption is that obtaining a recent compiler is as easy as rustup update stable.

The code in question was new in Shellharden 4.2.0. I checked that 4.1.3 builds with your version of rustc.

rbairwell commented 2 years ago

Thanks - that was enough of a hint to get me on my way and it now appears working!

It didn't occur to me to try and install a newer version of rust than the default Debian bullseye package manager apt offered (bulleyes being out since August 2021 and the version I'm running being released March 2022)

What I had to do was uninstall the default debian version of rust (1.48.0: from 2020-11-19 and then install rustup which left me with rust 1.62 from 2022-06-30 and cargo 1.62

For any other people which have this issue, try:

sudo apt-get remove rustc 
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install shellharden