Closed codeitlikemiley closed 2 years ago
Same problem
Please try to call RUST_LOG=fnm=debug fnm env
instead of fnm env
and send here the output 😃
Please try to call
RUST_LOG=fnm=debug fnm env
instead offnm env
and send here the output 😃
Does this work on windows, this is the results from Powershell preview
$env:RUST_LOG="debug" ; fnm env
error: Can't infer shell!
fnm can't infer your shell based on the process tree.
Maybe it is unsupported? we support the following shells:
* cmd
* powershell
* bash
* zsh
* fish
Should work. Do you know what the executable name is of PowerShell preview?
It is still pwsh.exe
, but it doesn't work anymore. Could be a permissions issue in Windows 11.
@rhacker Ahhhh now I see that I did not add the debug logging in Windows. I'm an idiot. Sorry!
the free Windows dev-VM is still Windows 10 and worked perfectly for me. Can you try cloning the repo and building it from source, and change the following line:
into something like:
that would be a great (and fairly simple) contribution, and would help debug your case 😃 🙏
Found the reason: wmic
was deprecated earlier this year, and is no longer there in the latest Insiders build. https://docs.microsoft.com/en-us/windows/win32/wmisdk/wmic
You could perhaps replace it with tasklist.exe
?
tasklist.exe
does not seem to provide parent process id. Do you know any alternatives? Or maybe it does support it and it is not documented? I'm not a Windows user :(
tasklist.exe
does not seem to provide parent process id. Do you know any alternatives? Or maybe it does support it and it is not documented? I'm not a Windows user :(
I'm not sure if this works for us
$p = Get-Process pwsh
$p.Parent.Id
15024
15024
it's powershell script, to spin powershell process with command, we can try powershell.exe --comand "<command-above>"
not so familiar with rust, I have tried to print! out some debug message in the infer/windows.rs
but it doesn't seem to work.
I will try taking a look on my free time. I'm not a Windows user so I will try migrating off wmic
, but I don't know if this will work on Win11. The VM I will use is https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/
I think you might need the windows 11 insider latest build to get this error.
@Schniz This command might work, but you will need to skip the first line of the the output, and possibly handle quoting. I don't know Rust at all, so I can't help...
let stdout = std::process::Command::new("powershell")
.args(&[
"-command",
"Get-CimInstance",
"-ClassName",
"win32_process",
"|",
"Select-Object",
"-property",
"\"ProcessID\",\"ParentProcessID\",\"Name\"",
"|",
"ConvertTo-CSV",
])
The output of the command looks like this:
#TYPE Selected.Microsoft.Management.Infrastructure.CimInstance
"ProcessID","ParentProcessID","Name"
"0","0","System Idle Process"
"4","0","System"
"168","4","Secure System"
"248","4","Registry"
You should be able to test this in your Windows 10 VM.
Amazing @dabide! Let me play with it
I was too tired last night, but now I managed to get it to work, and created a PR. 😄
@Schniz But perhaps it would be faster to use this instead of spinning up an external command? https://docs.rs/sysinfo/0.3.19/sysinfo/trait.SystemExt.html#tymethod.get_process_list
@Schniz But perhaps it would be faster to use this instead of spinning up an external command? https://docs.rs/sysinfo/0.3.19/sysinfo/trait.SystemExt.html#tymethod.get_process_list
Interesting! This can simplify the code if it supports all platforms. The most updated version is https://docs.rs/sysinfo/0.20.5/sysinfo/trait.SystemExt.html#tymethod.processes
And I was concerned about spawning PowerShell performance hit so it can be amazing to use this crate
Seems that it is supported on all platforms: https://docs.rs/sysinfo/0.20.5/sysinfo/index.html#supported-oses
There is a workaround, @codeitlikemiley : You can specify the shell on the command line, like this: fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression
@dabide thanks for this, it works perfectly fine :)
I really think about deprecating the automated shell check, it makes so much sense to just provide it when installing. The magic is fragile.
There is a workaround, @codeitlikemiley : You can specify the shell on the command line, like this:
fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression
works for me: fnm env --use-on-cd --shell power-shell | Out-String | Invoke-Expression
i am also facing this issue
Recently im facing this error,
Im using windows 11 , and before im not facing this issue, i did try to reinstall fnm and build from cargo but the error persist.
is there a way to fix this? Only in windows this is persisting, im using it in all my dev machine, artix linux, mac big sur no problem.
hope this will be resolve coz the command wont simple generate the correct fnm path for windows now. so the command node and npm are both not found.
i just use pure node js installation for now until this is resolve thanks for building fnm