-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] 'CC' is not recognized as an internal or external command #20671
Comments
It's weird. PIO will install toolchain before our script runs. I just deleted all my toolchains and added a log to our build script, here:
As you can see, the toolchain is installed before. I will take a look how this behave on windows and check if it's a PIO issue or a bug in our build script. There's a strong possibly of the users are using an outdated version that didn't properly search for the correct compiler (in old versions, we fail to find the compiler in some paths). |
I've asked the latest poster that had this problem about the version and he says that it was a fresh git clone of the default branch (https://community.platformio.org/t/stm32f103rc-btt-512k-does-not-compile-in-vscode-platformio-ide/18270/7?u=maxgerhardt). However in that particular thread the problem seems to have been that the toolchain download was corrupted. The question is whether that is the only case that that can occur, because in the first linked thread it was just reported to be working after install GCC (although that was also with the NXP platform and not STM32) |
This is our code that search by the current PIO compiler:
First, it checks for Is it possible that some users have a windows install and the compiler name not end with |
The compiler packages for Windows all have I'll check back with the user and let him execute the search script with a bit more verbose output. import os
import re
import time
Import("env")
#print(env.Dump())
# Find the current platform compiler by searching the $PATH
# which will be in a platformio toolchain bin folder
path_regex = re.escape(env['PROJECT_PACKAGES_DIR'])
gcc = "g++"
if env['PLATFORM'] == 'win32':
path_separator = ';'
path_regex += r'.*\\bin'
gcc += ".exe"
else:
path_separator = ':'
path_regex += r'/.+/bin'
# Search for the compiler
time.sleep(1)
print("PATH: " + str(env['ENV']['PATH'].split(path_separator)))
for pathdir in env['ENV']['PATH'].split(path_separator):
if not re.search(path_regex, pathdir, re.IGNORECASE):
continue
print("Searching directory: " + str(pathdir))
for filepath in os.listdir(pathdir):
print("Searching file " + filepath + " (dir " + pathdir + ")")
if not filepath.endswith(gcc):
continue
# Use entire path to not rely on env PATH
filepath = os.path.sep.join([pathdir, filepath])
print("Compiler found: " + str(filepath))
env.Exit(0)
print("nothing found :(")
env.Exit(0) Because for me that works really reliably, e.g.
in even an ESP8266 project. |
Yes, we had a few iterations on that code, until we reached this final version, that seems (?) to solve all issues. I'm thinking to try use |
@maxgerhardt did you find anything? I didn't find any issue in my testes. |
The user that had the initial error hasn't responded to my PMs yet that would have gotten debug logs sadly. The current code works for me, too. |
Another user has the issue that a wrong path for avr-g++ is deduced. See https://community.platformio.org/t/issues-building-with-fresh-marlin-firmware-and-platformio-2-2-1/18552/24?u=maxgerhardt. The parsed path is just |
And another user just came in with the same problem: https://community.platformio.org/t/help-compiling-marlin-2-0-x-for-the-first-time/18610 |
By his log, he downloaded Marlin '2.0.x' branch, that really doesn't have all corrections! @thinkyhead: can you merge this #19929 and #19881 on |
I replicated this by accident - my impatience turned out to be the cause here. The toolchain wasn't fully downloaded, but the system thought it was due the download being started. I deleted Basically, don't be impatient and it should compile fine in Windows. |
I've seen at least one case where the toolchain binary was fully present though. I'll keep it in mind and recommend this to other users in the future though as a debugging step. The last user just reported that it works on a different PC (doesn't give the cause though). In the thread before that, the GCC invocation fails with non-zero error code unexplicably, because if one manually executes it, it executes OK (and no Antivirus software is installed..). So this is all pretty much a mystery to me. |
I was having the exact same issue (cc not recognized) with W10 and PlatformIO. Building the current Marlin 2.0.x release from Github. I deleted .platformio folder as @simonsickle suggested and I'm at least able to build an unmodified Marlin.. |
I had the same problem today, after debugging i found that the common-dependencies.py forces the packages to be in the PATH variable. the ppl getting this error may have changed the directories, too. it worked months ago. This makes overriding the packages dir invalid, cause the marlin project dir is not in PATH.
I override the dirs, cause i dont want everything on my SSD. the search_compiler function gets the env['PROJECT_PACKAGES_DIR'] why is it looping the PATH now? this makes no sense for me, Marlin/buildroot/share/PlatformIO/scripts/common-dependencies.py Lines 194 to 218 in 5ee1087
|
PIO will put the toolchain bin folder (where the compiler is located) in the path... the toolchain is installed in the packages dir... The PATH will have something like that: PATH=PACKAGES_DIR/toolchain-gcc-foo-bar/bin:ETC:ETC:ETC... So we just look for GCC executable in the folders that are both in the packages dir and in the PATH. I never edited packages_dir config, but I expect that it should reflect on |
no, if u edit it like i did, PIO uses the abosulte path (
|
What is in your PATH? The toolchain should be in your path in some way... If not, any build will fail, not only our script. |
for me, it works until I change the board and environment in pio.ini then I get this error aswell |
More info, please. Did you try delete your .pio folder? And your ~/.platformio/packages folder? I'm keeping it open for a while, just gather more info. But until now, everything points that there's no bug at all. What is happening is partial download or corrupted pio installation. |
I just fixed this exact issue -> I only had to delete the platformio folder from the extensions folder then reinstalled PlatformIO and restarted VS Code -> no more error :) I'm going to go with a corrupt installation for my case... After the second install I noticed I didn't receive the Restart notification on the first install. Hope this helps . |
Works for my tooooo!!!! |
I'm so glad I found this, it worked for me as well. I think when I very first started learning how to do this (which was only about 2 months ago) I created a virtual environment through the command line but I had no idea what I was doing and I think that might have been what got me off course because I've been compiling just fine on two other machines but on this one I have never gotten one successful compile until just now. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug Description
Upon compilation, some (many?) users experience an error of the type
and report it to the PlatformIO forums.
Configuration Files
None relevant.
Steps to Reproduce
gcc
) is in the globalPATH
Expected behavior:
It builds beause it either can find the PlatformIO provided compiler, or gives a meaningful error message.
Actual behavior:
Additional Information
Often occurs as a topic in the PlatformIO forums, e.g.
The current code for finding the compiler was added in #18721
The PR by @rhapsodyv says that PlatformIO does not correctly expose the compiler in some cases on Windows (no further details or reproduction given though, so I can only guess the reproduction steps above). I can imagine that that can be the case in a first-install scenario when not even packages like
toolchain-atmelavr
(or the one for the platform) are downloaded yet.In such a case though the compiler would be downloaded after a first initial build.
If PlatformIO still exposes an incorrect compiler path after that, then it must be a core bug and handled in https://github.com/platformio/platformio-core/issues.
In any case, if extracting the compiler path fails, the Marlin scripts should recognize that by catching the
CalledProcessError
exception thrown in the stacktrace above, and inform the user about the possibilities (do rebuild, install global GCC [which seems to always work]).Possibly related issues are #18720 and #18959.
The text was updated successfully, but these errors were encountered: