Repository navigation
Closed
Labels
Resolution-ExternalThe issue is caused by external component(s).The issue is caused by external component(s).
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
I installed 7.3.0 with msi and after that kept getting the error like when executing gcloud commands
google-cloud-sdk\platform\bundledpython\python.exe: can't find '__main__' module in ''
Tried to reinstall gcloud (with and without bundled python) and powershell a few times without much luck.
Works fine after downgrade to PS 7.2.5
Expected behavior
PS C:\> gcloud -h
Usage: gcloud [optional flags] <group | command>
group may be access-approval | access-context-manager |
active-directory | ai | ai-platform | anthos |
api-gateway | apigee | app | artifacts | asset |
assured | auth | batch | beta | bigtable | billing |
bms | builds | certificate-manager | cloud-shell |
components | composer | compute | config | container |
data-catalog | database-migration | dataflow |
dataplex | dataproc | datastore | datastream | debug |
deploy | deployment-manager | dns | domains |
edge-cloud | emulators | endpoints |
essential-contacts | eventarc | filestore | firebase |
firestore | functions | game | healthcare | iam | iap |
identity | ids | iot | kms | logging | memcache |
metastore | ml | ml-engine | monitoring |
network-connectivity | network-management |
network-security | network-services | notebooks |
org-policies | organizations | policy-intelligence |
policy-troubleshoot | privateca | projects | pubsub |
recaptcha | recommender | redis | resource-manager |
resource-settings | run | scc | scheduler | secrets |
service-directory | services | source | spanner | sql |
storage | tasks | topic | transcoder | transfer |
workflows | workspace-add-ons
command may be cheat-sheet | docker | feedback | help | info | init |
survey | version
For detailed information on this command and its flags, run:
gcloud --helpActual behavior
PS C:\> gcloud -h
google-cloud-sdk\platform\bundledpython\python.exe: can't find '__main__' module in ''Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.3.0
PSEdition Core
GitCommitId 7.3.0
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response
Reacted by Aleksandr Chebotov, Serhii Rohoza, dewydex, Guilhem Vellut, Eric Rosenquist, Adrian Wiik, Angus Maiden, Ahmed Fwela, mbrownnycnyc, SalimGangji and 2 more
Metadata
Metadata
Assignees
Labels
Resolution-ExternalThe issue is caused by external component(s).The issue is caused by external component(s).
Activity
arifinsiam commentedon Nov 11, 2022
facing the same issue, have you found any solutions yet?
cesarjosue-reyes commentedon Nov 11, 2022
Same issue
al-cheb commentedon Nov 11, 2022
There is no any issue with PowerShell Desktop.
al-cheb commentedon Nov 12, 2022
#13428 (comment)
Workaround is to set
$PSNativeCommandArgumentPassing = "Legacy"- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Preference_Variables?view=powershell-7.3#psnativecommandargumentpassingandykcfung commentedon Nov 14, 2022
Another workaround is to start "cmd" inside powershell, login and then exit the "cmd" shell.
andykcfung commentedon Nov 14, 2022
FWIW, "PowerShell Desktop" is a very old version of PowerShell. Run the command "$PSVersionTable" on mine and it shows "PSVersion" to be 5.1.x
SteveL-MSFT commentedon Nov 14, 2022
If someone can confirm that setting
$PSNativeCommandArgumentPassing = "Legacy"works andgcloudworks, we can add that to legacy list so that it defaults to previous behavior. Also, is the actual commandgcloud.exeorgcloud.cmd? The latter should automatically use legacy passing.SerhiiRohoza commentedon Nov 14, 2022
Works for me.
daxian-dbw commentedon Nov 16, 2022
Re-open this issue.
Running gcloud is not running gcloud.exe, but resolved to the gcloud.ps1 file under the installation folder. The gcloud.ps1 file eventually calls python.exe with a generated argument array. For the gcloud -h, the generated argument array is essentially the following array:
The leading empty string is the problem that cause it fail in the new Standard/Windows mode. With legacy mode, the leading empty string is ignored when passing to python.exe, but with the new standard/windows mode, the empty string is passed in as well, which causes
python.exeto fail.gcloudwill be removed from the list by #18575.For now, setting
$PSNativeCommandArgumentPassing = "Legacy"is the workaround to usegcloudin PS 7.3.0SteveL-MSFT commentedon Nov 16, 2022
Created https://issuetracker.google.com/issues/259295558
veleek commentedon Nov 30, 2022
For anybody who runs into this issue and is looking for a quick workaround. Open up
gcloud.ps1(you can get the path usingGet-Command gcloud | Select-Object Source) and then replace Line 109:with
catosaurusrex2003 commentedon Dec 25, 2022
may not be related to the real problem of this error but i was getting the exact same error and
my error got SOLVED
the problem was that while installing gcloud CLI i installed it just for my user on C drive , whereas i was calling gcloud outside of the user path.
then i opened powershell inside user and then gcloud started to work
alteredego commentedon Jan 18, 2023
I can confirm that this has now been fixed with Google Cloud CLI version 413.0.0
https://issuetracker.google.com/issues/259295558