Can't build in Gitlab CI

Hi,

I’m trying to build my project from Gitlab CI. I have my runner installed locally and configured to ‘shell’. I have confirmed that I am in the correct directory in Gitlab CI. If I run “pio run” from the command line at that location, the project builds. If I run the same command from CI, I get the following output:

$ pio run
Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 1.12.0 > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 3.10004.200129 (1.0.4) 
 - tool-esptoolpy 1.20600.0 (2.6.0) 
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Looking for PubSubClient library in registry
Found: https://platformio.org/lib/show/89/PubSubClient
LibraryManager: Installing id=89
Downloading...
Unpacking...
PubSubClient @ 2.7 has been successfully installed!
Found 30 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <SPI> 1.0
|-- <PubSubClient> 2.7
|-- <MasterSPI>
|   |-- <SPI> 1.0
|-- <WifiManager> 0.99.9
|   |-- <DNSServer> 1.1.0
|   |   |-- <WiFi> 1.0
|   |-- <EEPROM> 1.0.3
|   |-- <PubSubClient> 2.7
|   |-- <WebServer> 1.0
|   |   |-- <WiFi> 1.0
|   |   |-- <FS> 1.0
|   |-- <WiFi> 1.0
|-- <DNSServer> 1.1.0
|   |-- <WiFi> 1.0
|-- <WebServer> 1.0
|   |-- <WiFi> 1.0
|   |-- <FS> 1.0
|-- <WiFi> 1.0
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Generating partitions .pio\build\esp32dev\partitions.bin
Compiling .pio\build\esp32dev\lib8c3\SPI\SPI.cpp.o
xtensa-esp32-elf-g++: error: CreateProcess: No such file or directory
xtensa-esp32-elf-g++: error: C:\Windows\system32\config\systemprofile\.platformio\packages\framework-arduinoespressif32\libraries\SPI\src\SPI.cpp: No such file or directory
xtensa-esp32-elf-g++: fatal error: no input files
compilation terminated.
Compiling .pio\build\esp32dev\lib2cb\PubSubClient_ID89\PubSubClient.cpp.o
xtensa-esp32-elf-g++: error: CreateProcess: No such file or directory
Compiling .pio\build\esp32dev\lib618\MasterSPI\MasterSPI.cpp.o
xtensa-esp32-elf-g++: error: CreateProcess: No such file or directory
Compiling .pio\build\esp32dev\lib872\WiFi\ETH.cpp.o
Compiling .pio\build\esp32dev\lib872\WiFi\WiFi.cpp.o
xtensa-esp32-elf-g++: error: C:\Windows\system32\config\systemprofile\.platformio\packages\framework-arduinoespressif32\libraries\WiFi\src\ETH.cpp: No such file or directory
xtensa-esp32-elf-g++: fatal error: no input files
compilation terminated.
Compiling .pio\build\esp32dev\lib872\WiFi\WiFiAP.cpp.o
xtensa-esp32-elf-g++: error: C:\Windows\system32\config\systemprofile\.platformio\packages\framework-arduinoespressif32\libraries\WiFi\src\WiFi.cpp: No such file or directory
xtensa-esp32-elf-g++: fatal error: no input files
compilation terminated.
Compiling .pio\build\esp32dev\lib872\WiFi\WiFiClient.cpp.o
xtensa-esp32-elf-g++: error: C:\Windows\system32\config\systemprofile\.platformio\packages\framework-arduinoespressif32\libraries\WiFi\src\WiFiAP.cpp: No such file or directory
xtensa-esp32-elf-g++: fatal error: no input files
compilation terminated.
Compiling .pio\build\esp32dev\lib872\WiFi\WiFiGeneric.cpp.o
xtensa-esp32-elf-g++: error: C:\Windows\system32\config\systemprofile\.platformio\packages\framework-arduinoespressif32\libraries\WiFi\src\WiFiClient.cpp: No such file or directory
xtensa-esp32-elf-g++: fatal error: no input files
compilation terminated.
Compiling .pio\build\esp32dev\lib872\WiFi\WiFiMulti.cpp.o
xtensa-esp32-elf-g++: error: C:\Windows\system32\config\systemprofile\.platformio\packages\framework-arduinoespressif32\libraries\WiFi\src\WiFiGeneric.cpp: No such file or directory
xtensa-esp32-elf-g++: fatal error: no input files
compilation terminated.
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1
*** [.pio\build\esp32dev\lib8c3\SPI\SPI.cpp.o] Error 1
Compiling .pio\build\esp32dev\lib872\WiFi\WiFiSTA.cpp.o
*** [.pio\build\esp32dev\lib2cb\PubSubClient_ID89\PubSubClient.cpp.o] Error 1
*** [.pio\build\esp32dev\lib618\MasterSPI\MasterSPI.cpp.o] Error 1
*** [.pio\build\esp32dev\lib872\WiFi\ETH.cpp.o] Error 1
*** [.pio\build\esp32dev\lib872\WiFi\WiFi.cpp.o] Error 1
*** [.pio\build\esp32dev\lib872\WiFi\WiFiAP.cpp.o] Error 1
*** [.pio\build\esp32dev\lib872\WiFi\WiFiClient.cpp.o] Error 1
*** [.pio\build\esp32dev\lib872\WiFi\WiFiGeneric.cpp.o] Error 1
xtensa-esp32-elf-g++: error: C:\Windows\system32\config\systemprofile\.platformio\packages\framework-arduinoespressif32\libraries\WiFi\src\WiFiMulti.cpp: No such file or directory
xtensa-esp32-elf-g++: fatal error: no input files
compilation terminated.
*** [.pio\build\esp32dev\lib872\WiFi\WiFiMulti.cpp.o] Error 1
xtensa-esp32-elf-g++: error: C:\Windows\system32\config\systemprofile\.platformio\packages\framework-arduinoespressif32\libraries\WiFi\src\WiFiSTA.cpp: No such file or directory
xtensa-esp32-elf-g++: fatal error: no input files
compilation terminated.
*** [.pio\build\esp32dev\lib872\WiFi\WiFiSTA.cpp.o] Error 1
========================== [FAILED] Took 5.27 seconds ==========================


ERROR: Job failed: exit status 1

Can anyone point me in the right direction to solve this? Thanks in advance!

Weird path for it to look for PlatformIO packages. Seems like it it’s running with super-elevated administrator rights if it looks there?

What’s the content of the .gitlab-ci.yml file?

Here’s my .gitlab-ci.yml:

stages:
 - build
 
before_script:
 - "pip install -U platformio"
 
BuildMM_Software:
 stage: build
 script:
 - dir
 - pio run

There’s not much to it, I just put the dir command in so I can be sure it’s running in the correct directory.

I also tried running pio run from an elevated command line in that directory and it ran just fine.

Despite the missing image: python:2.7 part it seems pretty equivalent to what the docs say the file should look like.

@ivankravets What could be the reason that PlatformIO thinks its framework path is C:\Windows\system32\config\systemprofile\.platformio\packages\framework-arduinoespressif32 instead of the normal user profile when executed in Gitlab on a Windows server?

Thanks for pointing that out. I added in the line image: python:2.7 at the beginning, but the behavior did not change. What is that supposed to do? Is it relevant if I’m building on my local machine?

Any new insights on this?

Still no idea why your environment behaves that way regarding that packages path. (@ivankravets?)

You can maybe have a play with the core_dir setting with a constant path and check if it still wants to access the framework files at C:\Windows..

Hi @jak888!
Strange, but I cannot reproduce the issue, Gitlab builds my basic project just fine. Is there anything special in your platformio.ini?

I suspect there is an issue with this on Windows since the install guide suggests to:

either run the service using the Built-in System Account (recommended) or using a user account.

If you run via an elevated command prompt, this probably screws up the profile path. Try and find out where your .platformio folder is… it’s probably in %userprofile%\.platformio. Once you’ve found it, you should be able to either hard-code that path into the .gitlab-ci.yml via the PLATFORMIO_CORE_DIR environment variable, or via the core_dir platformio.ini parameter Max mentioned earlier.

stages:
  # - test
  # - build
  # - deploy
  - prepare
  - release
variables:
  # /projects/:id/packages/generic/:package_name/:package_version/:file_name?status=:status
  PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}"
  BINARY: firmware
upload_assets:
  stage: prepare
  image: python:3.9
  before_script:
  - "pip install -U platformio"
  rules:
    - if: $CI_COMMIT_TAG
  script:
    - "pio run"
release_job:
  image: registry.gitlab.com/jaime/release-cli:latest
  stage: release
  needs:
    - upload_assets
  rules:
    - if: $CI_COMMIT_TAG
  script:
    - echo "Release $CI_COMMIT_TAG"
  release:
    name: "Release $CI_COMMIT_TAG"
    description: "Created using the release-cli"
    tag_name: $CI_COMMIT_TAG
    assets:
      links:
        - name: 'firmware'
          url: "${PACKAGE_REGISTRY_URL}/${BINARY}"
          filepath: '/.pio/build/esp32doit-devkit-v1/firmware'
          link_type: 'other'

may be this help