okta-aws-cli-assume-role: Windows 10 Error - Cannot run program "aws"

After installing the aws cli through python, I attempt to run awscli.bat, and get the following error:

Exception in thread "main" java.io.IOException: Cannot run program "aws": CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(Unknown Source)
        at com.okta.tools.awscli.main(awscli.java:36)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        ... 2 more

My initial guess was an issue with the way my PATH variable was setup, but running aws from the command line resolves correctly, and it also looks like the correct directory C:\Program Files\Python36\Scripts has been added to the PATH.

Can you all identify anything that I may have missed in order to execute this command correctly?

Below is execution of aws from Powershell with Admin access. The same result also occurs from my user-level account.

PS C:\> aws
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help
aws: error: the following arguments are required: command

This is a snapshot of my system-level environment variables. I have included the Python paths in both User and System.

image

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 25 (1 by maintainers)

Commits related to this issue

Most upvoted comments

It seems that Windows users need to install the AWS CLI using the MSI Installer. The Okta AWS CLI Assume Role tool does not work with the AWS CLI installed using pip.

@testworksau you’re right

Changing this: https://github.com/oktadeveloper/okta-aws-cli-assume-role/blob/eb6904319026f09f0c2710f5d6c819653cc32cd5/bin/Install-OktaAwsCli.ps1#L85 To this:

With-Okta -Profile $Profile ((Get-Command aws).Name) --profile $Profile @args

Fixes the issue solidly regardless of whether the command file is aws or aws.cmd.

Sure. I’ll have some time this week. 👍

Looking into this a bit further, it looks like there is a bug which causes okta-aws-cli-assume-role to fail when using python3 and aws-cli. @AlainODea @dlgoodr

How to Reproduce

  • Clean slate. Remove all versions of python and aws-cli
  • Install Python 3.x
  • Install aws-cli using either pip or the upgraded AWS CLI MSI installers (https://s3.amazonaws.com/aws-cli/AWSCLI64PY3.msi)
  • Run the assume-role tool and it should fail.

Notes

  • aws-cli for Python 2.7 uses an exe (aws.exe).
  • aws-cli for Python 3.x uses a cmd (aws.cmd).
  • even if you have python 2.7 already installed, and some previously installed version of the aws-cli, and aws.cmd is located in say, C:\python27\Scripts, it will fail. Basically you NEED to have the EXE version of the AWS cli or it simply will not work.
  • code here looks to genesis of the exception: awscli.java
  • FWIW procmon indicates that for a non-elevated command prompt, PATHEXT includes .CMD.

Totally disagree. awscli from pip on Windows works marvelously in all cases except for when used by okta-aws-cli-assume-role. The fact that the tool can’t support this use case is still a defect.

@mraible this can be closed. It’s an unrelated issue due to installing AWSCLI using PIP which doesn’t really work on Windows.