These are chat archives for rust-lang/rust

3rd
May 2019
deepgrace
@deepgrace
May 03 01:00
:)
Pascal Precht
@PascalPrecht
May 03 12:44

Hello there!

Does anybody here have experience with running rust programs on Azure Pipeline's Windows platforms?

I'm running into an issue where my tests fail on Windows, but not on the linux machines.

The program fails at executing another command using the Command API. That other command binary is installed via npm (e.g. npm install -g solc).

What's interesting: Running the command straight from the command line on CI works fine. Running it through my Rust program fails with a NotFound error.

Is there anything I need to keep in mind when using Rust's Command Apis on windows?

Ingvar Stepanyan
@RReverser
May 03 13:24
Particularly with npm "binaries" - yes
In fact, they're installed as .bat or other wrappers that call Node.js with corresponding script. Windows shell will happily add .exe / .bat / etc. for you, but Rust expects Command to accept a real well-specified path to a binary.
Ghost
@ghost~5cc2f941d73408ce4fbebebe
May 03 13:28
How to
dynamic allocating array in rust like malloc in c
matrixbot
@matrixbot
May 03 13:32
bspeice Do you just need an array of elements? If so, the vec![] macro is what you're looking for.
Pascal Precht
@PascalPrecht
May 03 13:34

In fact, they're installed as .bat or other wrappers that call Node.js with corresponding script. Windows shell will happily add .exe / .bat / etc. for you, but Rust expects Command to accept a real well-specified path to a binary.

@RReverser That is interesting! I'll look if I can find sth. in the std library for getting such path!

Ingvar Stepanyan
@RReverser
May 03 13:34
You can use which crate for getting a path, but you'll still need to explicitly invoke it with a shell.
Might be better to search for crates that abstract shell invocation away too.
Ghost
@ghost~5cc2f941d73408ce4fbebebe
May 03 13:36
@matrixbot but vector can be only single dimention
Pascal Precht
@PascalPrecht
May 03 13:36
Oh wait.. you mean using Command build doesn't do the trick even with a full path?
Ingvar Stepanyan
@RReverser
May 03 13:36
No, because it's still not an actual executable - you need to invoke cmd.exe to evaluate .bat.
https://doc.rust-lang.org/beta/std/process/struct.Command.html has example on how to call shell commands right at the top
Might be easier to just go there instead of trying to find full path.
And let the shell do the job for you.
matrixbot
@matrixbot
May 03 13:38
bspeice ebinshabu (Gitter): Right, and malloc only gives you a single-dimension buffer as well. You can easily construct vec![ vec![], vec![] ] if you want differently shaped data, or use something like ndarray if you want different dimensionality abstractions.
Pascal Precht
@PascalPrecht
May 03 13:44
Not sure what you're referring to @RReverser in those docs. They also just use the Command API (execpt that they check for windows and do -c vs \C). Is that what you mean?
To give a bit more context, this is the code I'm executing atm: https://github.com/PascalPrecht/vibranium/blob/master/src/compiler/strategy/solcjs.rs#L43-L47
Ahh! Noticed the sh vs cmd thing! Will give that a spin, thank you!
Ingvar Stepanyan
@RReverser
May 03 13:49
The point is that they invoke sh / cmd, but you're passing path to npm-installed "binary" as the actual command.
You need to invoke shell instead too, and pass that binary as an argument.
So that e.g. on Windows it would invoke cmd /C solcjs ... and not just solcjs ... - then you get correct behaviour for free.
Pascal Precht
@PascalPrecht
May 03 13:53
Yes, right, I got that now. Thank you so much! I guess it's better to use sh on Linux platforms too, even though it works without i?
Ghost
@ghost~5cc2f941d73408ce4fbebebe
May 03 14:18
@matrixbot if i create vector like this how will i input date to it
Ingvar Stepanyan
@RReverser
May 03 14:29

Yes, right, I got that now. Thank you so much! I guess it's better to use sh on Linux platforms too, even though it works without i?

Not sure TBH. I think without it is fine as well.

But yeah, either one should work.
Pascal Precht
@PascalPrecht
May 03 14:49
It works!! Thank yoou so so much!
Ingvar Stepanyan
@RReverser
May 03 14:49
You're welcome :)