Skip to content
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

Use crate isatty to resolve Windows build errors #14

Merged
merged 9 commits into from
Sep 24, 2017
Merged

Use crate isatty to resolve Windows build errors #14

merged 9 commits into from
Sep 24, 2017

Conversation

unv-annihilator
Copy link
Contributor

@unv-annihilator unv-annihilator commented Sep 6, 2017

Error was lack of isatty() method and failing to resolve enums in scope (full error message at bottom):

  • Remove custom isatty() functions in favor of using isatty::stdout_isatty()
  • Qualify NoColor/Color with Terminal:: in windows get_term()

Security Vulnerability:

  • Regenerated Cargo.lock so project is using newer hyper-tls version to resolve vulnerability (found with this tool).

Not essential to fix:

  • Removed semver and toml as they aren't used.
  • Swap cfg(unix) to cfg(not(windows)).
  • Cargo Fmt ran over the project.

Full build error:

     Running `rustc --crate-name cargo_audit C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\cargo-audit-0.2.0\src\main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C metadata=90ad0ec2f180ba3f -C extra-filename=-90ad0ec2f180ba3f --out-dir C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps -L dependency=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps --extern clap=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps\libclap-b56d578d70a144d9.rlib --extern term=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps\libterm-d309541b2c34d9be.rlib --extern rustsec=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps\librustsec-b5b0402bad69c859.rlib --extern semver=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps\libsemver-5939c48ed204a1a3.rlib --extern libc=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps\liblibc-11a7df87c7b71799.rlib --extern toml=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps\libtoml-1fccc4ceb3b64991.rlib --cap-lints allow`
error[E0425]: cannot find function `isatty` in this scope
  --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\cargo-audit-0.2.0\src\shell.rs:17:14
   |
17 |         tty: isatty(),
   |              ^^^^^^ not found in this scope
   |
help: possible candidate is found in another module, you can import it into scope
   |
14 | use libc::isatty;
   |

error[E0425]: cannot find function `NoColor` in this scope
  --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\cargo-audit-0.2.0\src\shell.rs:81:20
   |
81 |                 Ok(NoColor(Box::new(t)))
   |                    ^^^^^^^ not found in this scope
   |
help: possible candidate is found in another module, you can import it into scope
   |
14 | use shell::Terminal::NoColor;
   |

error[E0425]: cannot find function `Colored` in this scope
  --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\cargo-audit-0.2.0\src\shell.rs:83:20
   |
83 |                 Ok(Colored(Box::new(t)))
   |                    ^^^^^^^ not found in this scope
   |
help: possible candidate is found in another module, you can import it into scope
   |
14 | use shell::Terminal::Colored;
   |

error: aborting due to 3 previous errors

error: failed to compile `cargo-audit v0.2.0`, intermediate artifacts can be found at `C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb`

Caused by:
  Could not compile `cargo-audit`.

Caused by:
  process didn't exit successfully: `rustc --crate-name cargo_audit C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\cargo-audit-0.2.0\src\main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C metadata=90ad0ec2f180ba3f -C extra-filename=-90ad0ec2f180ba3f --out-dir C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps -L dependency=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps --extern clap=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps\libclap-b56d578d70a144d9.rlib --extern term=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps\libterm-d309541b2c34d9be.rlib --extern rustsec=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps\librustsec-b5b0402bad69c859.rlib --extern semver=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps\libsemver-5939c48ed204a1a3.rlib --extern libc=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps\liblibc-11a7df87c7b71799.rlib --extern toml=C:\Users\user\AppData\Local\Temp\cargo-install.cPThD60S9jYb\release\deps\libtoml-1fccc4ceb3b64991.rlib --cap-lints allow` (exit code: 101)

Error was due to lack of 'isatty()' method and failing to resolve enums in scope.
Removed semver and toml as they were unused.
Remove isatty() function infavor of isatty::stdout_isatty()
Swap cfg(unix) to cfg(not(windows))
Regenerate Cargo.lock to resolve older Hyper-Tls security vulnerability.
Cargo format ran over the project after change were made.
@tarcieri
Copy link
Member

tarcieri commented Sep 7, 2017

I'd feel a lot better about a Windows patch if there were Windows CI. Would it help if I set up something like Appveyor we could test it with?

@unv-annihilator
Copy link
Contributor Author

I have built and used this locally on my Windows 10 machine personally. That said I'm not a fan of 'works on my machine' so I understand wanting to run it through an official test. I don't have any experience setting up a windows CI w/ Appveyor but have seen a few examples with a quick search.

If there are any changes/additions you need me to make please let me know.

@tarcieri
Copy link
Member

Will look at setting up Appveyor this weekend. Sorry for the delay.

@tarcieri
Copy link
Member

Okay, took a bit longer than I said but I've set up Appveyor and it appears to be reproducing your reported problem:

https://ci.appveyor.com/project/tarcieri/cargo-audit/build/1.0.4/job/5ssqqoyg096brd9w

Can you rebase and see if it builds successfully now?

Error was due to lack of 'isatty()' method and failing to resolve enums in scope.
Removed semver and toml as they were unused.
Remove isatty() function infavor of isatty::stdout_isatty()
Swap cfg(unix) to cfg(not(windows))
Regenerate Cargo.lock to resolve older Hyper-Tls security vulnerability.
Cargo format ran over the project after change were made.
@unv-annihilator
Copy link
Contributor Author

Build is failing due to older Rust version on the windows machine.

Related Issues:

It's mentioned that rust 1.17.0 was when this was stabilized. https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1170-2017-04-27

@tarcieri
Copy link
Member

tarcieri commented Sep 24, 2017

Okay, try rebasing on master again. I tried a different Appveyor config which appears to successfully be pulling in Rust 1.20 stable using rustup: #16

Error was due to lack of 'isatty()' method and failing to resolve enums in scope.
Removed semver and toml as they were unused.
Remove isatty() function infavor of isatty::stdout_isatty()
Swap cfg(unix) to cfg(not(windows))
Regenerate Cargo.lock to resolve older Hyper-Tls security vulnerability.
Cargo format ran over the project after change were made.
@tarcieri
Copy link
Member

It's green! 🎉

Anything else you want to do before I merge? (e.g. squash) Otherwise I'm fine to merge as-is

@unv-annihilator
Copy link
Contributor Author

If you can't squash on merge then let me know and I can look into doing it on my side. Just re-formatted it with the latest rustfmt-nightly. Otherwise I'm fine with merging as-is.

@tarcieri tarcieri merged commit 5209055 into rustsec:master Sep 24, 2017
@tarcieri
Copy link
Member

Released as v0.2.1

tarcieri added a commit that referenced this pull request May 7, 2021
Factor integration tests into the tests/ directory
tarcieri added a commit that referenced this pull request May 7, 2021
metadata: Generalize into `Key` and `Value` types
tarcieri added a commit that referenced this pull request May 7, 2021
tarcieri added a commit that referenced this pull request May 7, 2021
tarcieri added a commit that referenced this pull request May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants