'.' is not recognized as an internal or external command on Windows 11
Closed this issue · 5 comments
After getting everything setup with AWS and running in the cloud, I am looking at the docs to run the app locally.
The first step is to setup AWS credentials profile. However the command fails:
> pnpm run aws:profile
> @baselinejs/core@0.0.9 aws:profile C:\Users\timof\repos\timo\kogs
> ./scripts/setup-aws-profile.sh
'.' is not recognized as an internal or external command,
operable program or batch file.
ELIFECYCLE Command failed with exit code 1.
I am on Windows 11 with the following versions:
- node v20.11.1
- pnpm 9.4.0
- aws aws-cli/2.17.4 Python/3.11.8 Windows/10 exe/AMD64
- java 1.8.0_411
This happens in a Windows prompt, as well as in the VSCode bash shell command prompt.
I supposed that error was coming from this line in the scripts\setup-aws-profile.sh:
# Sets REGION, APP_NAME, AWS_REGION, AWS_PROFILE
. ./scripts/project-variables.sh
However, updating that to try some variations doesn't fix the issue, and even removing that file doesn't help.
I'm not sure which command should come first, but pnpm run generate:env:local
results in the exact same error.
Shell scripts will not work in Windows command prompt. Baseline only works on Windows when using the Windows Subsystem for Linux (for now). I would recommend trying it out
https://learn.microsoft.com/en-us/windows/wsl/install
https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-vscode
Thanks for that @thomas-nixon-baseline.
Since installing WSL creates a blank slate OS, I thought I would include notes here on installing all the development tools needed as per the Baseline docs in case it can help others.
The requirements
- Node.js v20
- pnpm version 9
- AWS CLI v2
- jq for extracting Cloudformation outputs
- Java (JRE) version 8.x
- curl
Installing Git
sudo apt-get install git
$ git --version
git version 2.34.1
Installing Node with NVM
sudo apt-get install curl build-essential libssl-dev
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
nvm install 20
nvm use 20
node --version
v20.15.0
pnpm -v
9.4.0
Install Java runtime
sudo apt install default-jre
java -version
openjdk version "11.0.23" 2024-04-16
OpenJDK Runtime Environment (build 11.0.23+9-post-Ubuntu-1ubuntu122.04.1)
OpenJDK 64-Bit Server VM (build 11.0.23+9-post-Ubuntu-1ubuntu122.04.1, mixed mode, sharing)
Install jq for extracting Cloudformation outputs
sudo apt-get install jq
Install AWS Command Line Interface
sudo apt-get install awscli
aws --version
aws-cli/1.22.34 Python/3.10.12 Linux/5.15.146.1-microsoft-standard-WSL2 botocore/1.23.34
Current issues
After all this, I see a different error now when trying to setup my AWS profile:
$ pnpm run aws:profile
> @baselinejs/core@0.0.9 aws:profile /mnt/c/Users/timof/repos/timo/kogs
> ./scripts/setup-aws-profile.sh
/usr/bin/env: ‘bash\r’: No such file or directory
ELIFECYCLE Command failed.
WARN Local package.json exists, but node_modules missing, did you mean to install?
$ npm i
npm notice
npm notice New minor version of npm available! 10.7.0 -> 10.8.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.1
npm notice To update run: npm install -g npm@10.8.1
npm notice
npm error code EUNSUPPORTEDPROTOCOL
npm error Unsupported URL Type "workspace:": workspace:1.0.0
As an update to this issue (Windows user setup), StackOverflow, says the ‘bash\r’: No such file or directory
error message suggests that the script you're invoking has embedded \r characters, which in turn suggests that it has Windows-style \r\n line endings (newlines) instead of the \n-only line endings bash expects. As a quick fix, you can remove the \r chars. as follows
sed $'s/\r$//' ./scripts/generate-env-vars.sh > ./scripts/generate-env-vars.sh.temp
Then delete the original and rename the 'temp' string at the end of the new filename. I had to do the same to:
- generate-env-vars.sh
- project-variables.sh
- get-stack-outputs.sh.unix
Then running the generate command again completes:
$ pnpm run generate:env:local
> @baselinejs/core@0.0.9 generate:env:local /mnt/c/Users/timof/repos/timo/kogs
> ./scripts/generate-env-vars.sh local
App Name: [kogs]
Profile: [kogs]
Region: [ap-southeast-2]
Stack Stage: [local]
The config profile (kogs) could not be found
The config profile (kogs) could not be found
The config profile (kogs) could not be found
The config profile (kogs) could not be found
[./web/.env.development] has been generated successfully!
[./admin/.env.development] has been generated successfully!
I think the missing config profile means this command has to be run first:
$ pnpm run aws:profile
> @baselinejs/core@0.0.9 aws:profile /mnt/c/Users/timof/repos/timo/kogs
> ./scripts/setup-aws-profile.sh
Setup AWS profile [kogs]
Enter the AWS Access Key: <your-key-here>
Enter the AWS Secret Key: <hope-you-took-note-of-this>
AWS Session Token (optional): <not-sure>
Configuring AWS....
No existing session token... ignoring
Testing AWS Keys...
Credentials work!
Done
Then, running generate again works:
$ pnpm run generate:env:local
> @baselinejs/core@0.0.9 generate:env:local /mnt/c/Users/timof/repos/timo/kogs
> ./scripts/generate-env-vars.sh local
App Name: [kogs]
Profile: [kogs]
Region: [ap-southeast-2]
Stack Stage: [local]
[./web/.env.development] has been generated successfully!
Also, a more lasting solution for the line endings might be to make Git check out files with Unix-style file endings on Windows:
git config --global core.autocrlf false
But this might interfere with other local projects.
I'm not sure if this is the proper solution for working with Baseline on Windows, but I will close this issue as the above did solve my issues.