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

x.ps1 complains Python isn't installed, even though it is installed and working #117067

Closed
xobs opened this issue Oct 23, 2023 · 2 comments · Fixed by #117069
Closed

x.ps1 complains Python isn't installed, even though it is installed and working #117067

xobs opened this issue Oct 23, 2023 · 2 comments · Fixed by #117069
Assignees
Labels
C-bug Category: This is a bug. O-windows Operating system: Windows T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@xobs
Copy link
Contributor

xobs commented Oct 23, 2023

I tried this code:

powershell .\x.ps1 test

I expected to see this happen: Rust would build

Instead, this happened: x.ps1 complained that python is not installed

Meta

rustc --version --verbose:

rustc 1.75.0-nightly (cae0791da 2023-10-05)
binary: rustc
commit-hash: cae0791da47bb01f16885eb233dcd66b0093a6e1
commit-date: 2023-10-05
host: x86_64-pc-windows-msvc
release: 1.75.0-nightly
LLVM version: 17.0.2

Backtrace

[12:45:06 pm] E:/Code/Xous/rust-condvar-fixes> powershell .\x.ps1 test library/std
E:\Code\Xous\rust-condvar-fixes\x.ps1 : E:\Code\Xous\rust-condvar-fixes\x.ps1: error: did not find python installed
help: consider installing it from https://www.python.org/downloads/
At line:1 char:1
+ .\x.ps1 test library/std
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotInstalled: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,x.ps1

[12:45:15 pm] E:/Code/Xous/rust-condvar-fixes>

Additional Info

This works just fine if I comment out lines 20-24 of x.ps1:

diff --git a/x.ps1 b/x.ps1
index 55f99901645..eae1a2cb399 100755
--- a/x.ps1
+++ b/x.ps1
@@ -17,11 +17,6 @@ foreach ($arg in $args) {

 function Get-Application($app) {
     $cmd = Get-Command $app -ErrorAction SilentlyContinue -CommandType Application | Select-Object -First 1
-    if ($cmd.source -match '.*AppData\\Local\\Microsoft\\WindowsApps\\.*exe') {
-        # Windows for some reason puts a `python3.exe` executable in PATH that just opens the windows store.
-        # Ignore it.
-        return $false
-    }
     return $cmd
 }

I am using Python as installed from the Microsoft Store, which as far as I know is the recommended way to run Python on Windows:

[12:47:43 pm] E:/Code/Xous/rust-condvar-fixes> get-command "Python*"

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     python.exe                                         0.0.0.0    C:\Users\Sean\AppData\Local\Microsoft\WindowsApps\py…
Application     python3.10.exe                                     0.0.0.0    C:\Users\Sean\AppData\Local\Microsoft\WindowsApps\py…
Application     python3.exe                                        0.0.0.0    C:\Users\Sean\AppData\Local\Microsoft\WindowsApps\py…
Application     pythonw.exe                                        0.0.0.0    C:\Users\Sean\AppData\Local\Microsoft\WindowsApps\py…
Application     pythonw3.10.exe                                    0.0.0.0    C:\Users\Sean\AppData\Local\Microsoft\WindowsApps\py…
Application     pythonw3.exe                                       0.0.0.0    C:\Users\Sean\AppData\Local\Microsoft\WindowsApps\py…

[12:47:52 pm] E:/Code/Xous/rust-condvar-fixes> python3 --version
Python 3.10.11
[12:48:38 pm] E:/Code/Xous/rust-condvar-fixes> python --version
Python 3.10.11
[12:48:41 pm] E:/Code/Xous/rust-condvar-fixes>
@xobs xobs added the C-bug Category: This is a bug. label Oct 23, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 23, 2023
@albertlarsan68 albertlarsan68 self-assigned this Oct 23, 2023
@albertlarsan68 albertlarsan68 added O-windows Operating system: Windows T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 23, 2023
@albertlarsan68
Copy link
Member

Hello, and thanks for the report!
It was broken in #113008, which I warned about.
Do you mind submitting a PR removing those lines ?

@xobs
Copy link
Contributor Author

xobs commented Oct 23, 2023

PR submitted as 117067

@bors bors closed this as completed in cec7d4a Oct 23, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 23, 2023
Rollup merge of rust-lang#117069 - xobs:x.ps1-remove-windows-store-check, r=albertlarsan68

x.ps1: remove the check for Python from Windows Store

When installing Python from the Windows Store, a copy of `python.exe` is installed inder the Microsoft directory in the user's local AppData directory. Currently, `x.ps1` checks for this file, because by default running `python.exe` opens a link to the Microsoft Store rather than running Python.

Once the user installs Python, however, this contains a valid interpreter. Unfortuantely, `x.ps1` can't tell the difference between a legitimate Python install and the stub.

Remove the check, as it makes it impossible to use the official version from Microsoft once it has been installed.

This resolves rust-lang#117067
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-windows Operating system: Windows T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants