Sublime Forum

AWS S3 File Sync: How to fix “[WinError 2] System cannot find the file specified”

#1

Hi everyone,
I’m trying to sync my AWS S3 bucket with my local files using Sublime Text 3.

I have installed AWS CLI and configured with my S3 access keys.

To perform my desired oepration, I have created a file named s3sync.sublime-build which contains the following code:

{
"cmd":["aws","s3","sync","C:\\Users\\john\\OneDrive\\Documents\\folder\\sub 1\\sub 2","s3://s3url.com"]
}   

I then created a file called test.txt in my “sub 2” folder to test the sync/build system.

When I press “ctrl + B” I receive the following error:

[WinError 2] The system cannot find the file specified
[cmd: ['aws', 's3', 'sync','C:\\Users\\john\\OneDrive\\Documents\\folder\\sub 1\\sub 2', 's3://s3url.com']]
[dir: C:\Users\john\OneDrive\Documents\folder\sub 1\sub 2]
[path: C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\john\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\john\AppData\Local\Programs\Python\Python37\;C:\Users\john\AppData\Local\Microsoft\WindowsApps]
[Finished]

Thank you so much for any insight you can provide.

0 Likes

#2

As outlined in some of the comments on your SO question, your general issue is that aws is an application/script that Windows can’t find.

Specifically, when you use shell_cmd in a sublime-build file you’re telling Sublime that to execute the build it should ask the OS’s command interpreter (on Windows that’s cmd.exe) to execute the command. When you use cmd you’re telling Sublime that to execute the build it should ask the OS to directly execute the first argument in the cmd list, which in your case is aws.

The commonality here is that either way, it’s the operating system that is trying to run the program, but it can’t because it can’t find it. If you use shell_cmd then cmd.exe will tell you it doesn’t recognize the command and if you use cmd Windows tells you that it can’t find the thing you told it to run.

The solution in either case is to ensure that what’s being executed can be found in the PATH; the output in the build shows you the locations that Windows is looking for things.

In your case, if aws isn’t found in the PATH, it can’t be executed. You mentioned in the SO comments that it is a directory in the path. In that case, if it’s a script of some sort (perhaps a Python script) then the issue might be that when trying to execute the script Windows can’t find the Python interpreter, which would also need to be in the path.

This is sort of a long winded way of saying that if you can’t open a windows command prompt and execute a command by entering it’s name there, then Sublime isn’t going to be able to execute it either. If you modify the PATH to resolve the problem, you also need to restart Sublime so that it sees the update.

For what it’s worth, I have a video series that covers how sublime-build files work that you may find helpful to understand better what’s happening behind the scenes when you use the build command. This video covers issues like the one you’re seeing here and some ways to resolve the issue.

0 Likes