-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix NPM 'postinstall' task in Windows #1187
Conversation
Fixes #1179 Provide `getmake.py` with the absolute path in which it must place fetched stuff.
Let's see if CI passes. |
@nazar-pc please, tell me where mediasoup Rust installation calls the |
Sorry, found it. In |
@nazar-pc may you help here please? Here in if !std::path::Path::new("worker/out/msys/bin/make.exe").exists() {
let python = if Command::new("where")
.arg("python3.exe")
.status()
.expect("Failed to start")
.success()
{
"python3"
} else {
"python"
};
if !Command::new(python)
.arg("scripts\\getmake.py")
.status()
.expect("Failed to start")
.success()
{
panic!("Failed to install MSYS/make")
}
}
let python = if env::var("PYTHON") {
env::var("PYTHON")
} else if Command::new("where")
.arg("python3.exe")
.status()
.expect("Failed to start")
.success()
{
"python3"
} else {
"python"
};
BTW this PR is making Node+Windows CI pass :) https://github.com/versatica/mediasoup/actions/runs/6585288341/job/17891419544?pr=1187 |
|
What do I need that for? I mean, I assume that let python = if env::var("PYTHON") {
env::var("PYTHON")
} else if Command::new("where") |
No :) Solving it. |
No, it returns |
It's complaining about no permissions error:
|
There is no "bashbug" in the whole mediasoup repo.
|
worker/build.rs
Outdated
}; | ||
|
||
let worker_abs_path = env::current_dir().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect, Rust crates are not supposed to touch anything anywhere in the file system except a location where they are allowed to modify things defined by OUT_DIR
environment variable and already stored in out_dir
variable (also see mediasoup_out_dir
in case that is what you actually need here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
println!("--- mediasoup_out_dir: {}", mediasoup_out_dir);
// => mediasoup_out_dir: /Users/ibc/src/v3-mediasoup/target/debug/build/mediasoup-sys-11923be8cb8ca4cd/out/out
That's far from what I want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is actually precisely what you want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see that.
if !std::path::Path::new("worker/out/msys/bin/make.exe").exists() {
let python = if let Ok(python) = env::var("PYTHON") {
python
} else if Command::new("where")
.arg("python3")
.status()
.expect("Failed to start")
.success()
{
"python3".to_string()
} else {
"python".to_string()
};
let worker_abs_path = env::current_dir().unwrap();
let dir = worker_abs_path.join("out/msys");
if !Command::new(python)
.arg("scripts\\getmake.py")
.arg("--dir")
.arg(dir)
.status()
.expect("Failed to start")
.success()
{
panic!("Failed to install MSYS/make")
}
}
env::set_var(
"PATH",
format!(
"{}\\worker\\out\\msys\\bin;{}",
env::current_dir()
.unwrap()
.into_os_string()
.into_string()
.unwrap(),
env::var("PATH").unwrap()
),
);
- Here we first check
mediasoup/worker/out/msys/bin/make.exe
. - If it doesn't exist then we run
getmake.py
and we want to store things indir
(let's see below whatdir
should be). - Then we do this:
env::set_var( "PATH", format!( "{}\\worker\\out\\msys\\bin;{}", env::current_dir() .unwrap() .into_os_string() .into_string() .unwrap(), env::var("PATH").unwrap() ), );
- There we are clearly adding current dir + \worker\out\msys\bin to the
PATH
. - So it's very clear that
dir
given togetmake.py
must point to current dir + \worker\out\msys as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So everything was wrong before or there is something I miss.
In addition, it looks suspicious to me that mediasoup_out_dir
in my macOS points to "/Users/ibc/src/v3-mediasoup/target/debug/build/mediasoup-sys-11923be8cb8ca4cd/out/out" (note the double "out" at the end).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might, but probably because CI worked before too due to GitHub Actions containing correct make
, but when people install mediasoup on their machines, suddenly things break because make
in PATH
is nmake or whatever the thing is that is on Windows by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like that, yes. One out is from Cargo, second is "ours".
But how can it be wrong? I mean, mediasoup_out_dir
is being used by build.rs to give env MEDIASOUP_OUT_DIR
to make libmediasoup-worker
. How is possible that it was wrong all this time? I mean, can I just make mediasoup_out_dir
be out_dir
:
- let mediasoup_out_dir = format!("{}/out", out_dir.replace('\\', "/"));
+ let mediasoup_out_dir = out_dir.replace('\\', "/");
and things will work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That part isn't wrong, I meant get_make
and where it places downloaded files wasn't correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is gonna be fine: cca0dab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust is amazing. I declare a let dir
and it later complains because I have "moved" it so I cannot use it in two places and must clone it in one of them.
error[E0382]: borrow of moved value: `dir`
--> worker\build.rs:109:39
|
94 | let dir = format!("{}/msys", mediasoup_out_dir.replace('\\', "/"));
| --- move occurs because `dir` has type `std::string::String`, which does not implement the `Copy` trait
...
99 | .arg(dir)
| --- value moved here
...
109 | format!("{}\\bin;{}", dir, env::var("PATH").unwrap()),
| ^^^ value borrowed here after move
|
= note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
99 | .arg(dir.clone())
| ++++++++
Now this: https://github.com/versatica/mediasoup/actions/runs/6587295108/job/17897281193?pr=1187
I give up. |
Looks like you're trying to remove Try https://doc.rust-lang.org/stable/std/fs/fn.remove_dir_all.html instead |
So clean-all: clean-subprojects
$(RM) -rf $(MEDIASOUP_OUT_DIR)
|
WHAT??? Do you mean that the |
I mean it doesn't download |
Hell, there is |
|
Yes, I get it. So I have no idea about a proper solution for this other than placing |
Maybe using |
So I have to tell Makefile to use |
I have a better option: call |
yes |
@nazar-pc CI is passing!!!! |
executeCmd(`${pythonPath} worker\\scripts\\getmake.py`); | ||
const dir = path.resolve('worker/out/msys'); | ||
|
||
executeCmd(`${pythonPath} worker\\scripts\\getmake.py --dir="${dir}"`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cosmetic, this path could aslo be created with path.resolve()
and avoid the double back slashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but we don't follow an specific approach for that in the whole file. I agree we need consistency but I don't want to decide such a consistency within this PR.
Co-authored-by: José Luis Millán <[email protected]>
Fixes #1179
Provide
getmake.py
with the absolute path in which it must place fetched stuff.