alliedmodders / ambuild

AlliedModders C++ Build System
BSD 3-Clause "New" or "Revised" License
60 stars 32 forks source link

FileNotFoundError on windows #63

Closed Headline closed 4 years ago

Headline commented 5 years ago

I run into this a lot, but it seems only now it's interrupting my workflow. Tried a re-install of ambuild, and I'm on the latest version. Here's the stack trace I get from the console output when trying to build sourcemod on msvc 1900

Spawned taskmaster (pid: 5832)
Spawned worker (pid: 7424)
Spawned worker (pid: 10856)
Spawned worker (pid: 16956)
Spawned worker (pid: 16856)
Spawned worker (pid: 8820)
Spawned worker (pid: 11536)
Spawned worker (pid: 14548)
Spawned worker (pid: 10864)
Spawned worker (pid: 9268)
Spawned worker (pid: 11800)
Spawned worker (pid: 12780)
Spawned worker (pid: 1220)
Spawned worker (pid: 1904)
Spawned worker (pid: 8284)
Spawned worker (pid: 10020)
Spawned worker (pid: 5168)
Spawned worker (pid: 3356)
Spawned worker (pid: 12752)
Spawned worker (pid: 3996)
Spawned worker (pid: 16520)
Traceback (most recent call last):
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\ipc\windows.py", line 405, in processMessage
    listener.receiveMessage(channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\ipc\impl.py", line 67, in receiveMessage
    self.listener.receiveMessage(channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\ipc\process.py", line 150, in receiveMessage
    return self.messageMap[message['id']](channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 53, in <lambda>
    'task': lambda channel, message: self.receiveTask(channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 93, in receiveTask
    response = self.taskMap[task_type](message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 60, in <lambda>
    'rc': lambda message: self.doResource(message),
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 236, in doResource
    p, out, err = util.Execute(rc_argv)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\util.py", line 164, in Execute
    shell=shell
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
[8284] Child process terminating abnormally.
Traceback (most recent call last):
Traceback (most recent call last):
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\ipc\windows.py", line 405, in processMessage
    listener.receiveMessage(channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\ipc\impl.py", line 67, in receiveMessage
    self.listener.receiveMessage(channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\ipc\process.py", line 150, in receiveMessage
    return self.messageMap[message['id']](channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 53, in <lambda>
    'task': lambda channel, message: self.receiveTask(channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 93, in receiveTask
    response = self.taskMap[task_type](message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 60, in <lambda>
    'rc': lambda message: self.doResource(message),
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 236, in doResource
    p, out, err = util.Execute(rc_argv)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\util.py", line 164, in Execute
    shell=shell
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
Traceback (most recent call last):
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\ipc\windows.py", line 405, in processMessage
    listener.receiveMessage(channel, message)
[7424] Child process terminating abnormally.
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\ipc\windows.py", line 405, in processMessage
    listener.receiveMessage(channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\ipc\impl.py", line 67, in receiveMessage
    self.listener.receiveMessage(channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\ipc\process.py", line 150, in receiveMessage
    return self.messageMap[message['id']](channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 53, in <lambda>
    'task': lambda channel, message: self.receiveTask(channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 93, in receiveTask
    response = self.taskMap[task_type](message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 60, in <lambda>
    'rc': lambda message: self.doResource(message),
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 236, in doResource
    p, out, err = util.Execute(rc_argv)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\util.py", line 164, in Execute
    shell=shell
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
[10856] Child process terminating abnormally.
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\ipc\impl.py", line 67, in receiveMessage
    self.listener.receiveMessage(channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\ipc\process.py", line 150, in receiveMessage
    return self.messageMap[message['id']](channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 53, in <lambda>
    'task': lambda channel, message: self.receiveTask(channel, message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 93, in receiveTask
    response = self.taskMap[task_type](message)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 60, in <lambda>
    'rc': lambda message: self.doResource(message),
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\task.py", line 236, in doResource
    p, out, err = util.Execute(rc_argv)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ambuild2\util.py", line 164, in Execute
    shell=shell
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
[12752] Child process terminating abnormally.
Crashed trying to perform update:
Headline commented 5 years ago

here's a full build output from a clean python 3 installation

https://pastebin.com/tq510G0s

TheDS commented 5 years ago

So I've been able to reproduce this recently and I don't think it's an AMBuild bug per se. Notice that it's dying when it calls doResource which is where rc.exe is being invoked. If you start the VS2015 x86 Native Tools Command Prompt and try to run rc, you will probably find that it doesn't exist in the current path. This is the file which is not being found. This seems to be a problem when you have VS 2017 or 2019 installed along with the 2015 build tools.

Having searched the internet about rc.exe being missing, I've found that it seems to be a fairly common problem with no satisfying solution. I've tried repairing my install as well as uninstalling and reinstalling to no avail.

The problem lies in the path to the Windows SDK. By default (on my Windows 10 machine), it assumes the SDK tools are in C:\Program Files (x86)\Windows Kits\10\bin\x86 which has no executable in it. The batch script that the VS2015 Command Prompt shortcut invokes is located at C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat. The first argument is the platform (x86 or x64). Then there's a second argument for the Windows SDK version. On my machine I have SDKs installed for 8.1 and other builds of 10 such as 10.0.17763.0. These SDK locations do have rc.exe in them. The various builds of the 10 SDK can be seen in C:\Program Files (x86)\Windows Kits\10\bin.

Possible solutions I've found so far: 1) If you specify 8.1 as the second argument to the batch script, then rc can be run and AMBuild works nicely again. For some reason, using one of the 10.x.x versions does not. 2) Copy or make symbolic links for rc.exe and rcdll.dll from one of the SDK locations into C:\Program Files (x86)\Windows Kits\10\bin\x86 3) Add one of the other SDK version paths to your PATH environment variable. For example: set PATH=C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86;%PATH%

Could you confirm that the above is true for you as well?

All that said, I think it would be good to have a clearer error message from AMBuild when something like this happens. An error could say that rc couldn't be found. That's not immediately obvious from the error you get now unless you know what to look for.

dvander commented 4 years ago

While working on AMBuild's MSVC detection, I ran into this problem. Indeed the VS2015 build tools don't detect newer SDKs properly. The new detection logic will early abort if "rc.exe" is not found in path, so I think we can close this.

Since (1) MSVC 2015 is pretty old, and (2) it'll really only get used on our build machines, where we have to manually configure the environment anyway I didn't attempt to fix this further in our detection logic. But in theory we could, by enumerating the SDKs, and making sure one of them is in PATH.