Skip to content
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

Project generated do not build when normal esp-idf environment is sourced #204

Closed
PocketPi opened this issue Apr 2, 2024 · 9 comments
Closed

Comments

@PocketPi
Copy link

PocketPi commented Apr 2, 2024

Bug description

I have esp-idf v5.2.1 installed as im using that for my main project. I have now tried to make a rust project off the template but that do not build. This is what i get from the build process:

peter:~/data/code/esprs-test$ cargo build
   Compiling esp-idf-sys v0.34.1
The following warnings were emitted during compilation:

warning: [email protected]: Compiler version doesn't include clang or GCC: "cc" "--version"
warning: [email protected]: Compiler version doesn't include clang or GCC: "c++" "--version"

error: failed to run custom build command for `esp-idf-sys v0.34.1`

Caused by:
  process didn't exit successfully: `/home/peter/data/code/esprs-test/target/debug/build/esp-idf-sys-be56d55db34120ca/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=ESP_IDF_TOOLS_INSTALL_DIR
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG_DEFAULTS
  cargo:rerun-if-env-changed=MCU
  cargo:rerun-if-env-changed=ESP_IDF_SYS_ROOT_CRATE
  cargo:rerun-if-env-changed=ESP_IDF_VERSION
  cargo:rerun-if-env-changed=ESP_IDF_REPOSITORY
  cargo:rerun-if-env-changed=ESP_IDF_CMAKE_GENERATOR
  cargo:rerun-if-env-changed=IDF_PATH
  cargo:rerun-if-env-changed=EXTRA-COMPONENTS
  cargo:rerun-if-env-changed=ESP_IDF_COMPONENTS
  cargo:rerun-if-env-changed=ESP_IDF_COMPONENT_MANAGER
  cargo:rerun-if-changed=/home/peter/data/code/esprs-test/sdkconfig.defaults
  cargo:warning=Compiler version doesn't include clang or GCC: "cc" "--version"
  cargo:warning=Compiler version doesn't include clang or GCC: "c++" "--version"
  CMAKE_PREFIX_PATH_xtensa-esp32-espidf = None
  CMAKE_PREFIX_PATH_xtensa_esp32_espidf = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_xtensa-esp32-espidf = None
  CMAKE_xtensa_esp32_espidf = None
  TARGET_CMAKE = None
  CMAKE = None
  running: cd "/home/peter/data/code/esprs-test/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-95e72fc75916bcbf/out/build" && CMAKE_PREFIX_PATH="" EXTRA_COMPONENT_DIRS="" IDF_COMPONENT_MANAGER="1" IDF_PATH="/home/peter/data/tools/esp-idf" IDF_TARGET="esp32" PATH="/home/peter/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/peter/data/tools/esp-idf/components/espcoredump:/home/peter/data/tools/esp-idf/components/partition_table:/home/peter/data/tools/esp-idf/components/app_update:/home/peter/.espressif/tools/xtensa-esp-elf-gdb/12.1_20231023/xtensa-esp-elf-gdb/bin:/home/peter/.espressif/tools/riscv32-esp-elf-gdb/12.1_20231023/riscv32-esp-elf-gdb/bin:/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/peter/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin:/home/peter/.espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin:/home/peter/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/bin:/home/peter/.espressif/tools/xtensa-esp-elf-gdb/12.1_20231023/xtensa-esp-elf-gdb/bin:/home/peter/.espressif/tools/riscv32-esp-elf-gdb/12.1_20231023/riscv32-esp-elf-gdb/bin:/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/peter/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin:/home/peter/.espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin:/home/peter/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/bin:/home/peter/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/peter/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/peter/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/peter/data/tools/esp-idf/components/espcoredump:/home/peter/data/tools/esp-idf/components/partition_table:/home/peter/data/tools/esp-idf/components/app_update:/home/peter/.espressif/tools/xtensa-esp-elf-gdb/12.1_20231023/xtensa-esp-elf-gdb/bin:/home/peter/.espressif/tools/riscv32-esp-elf-gdb/12.1_20231023/riscv32-esp-elf-gdb/bin:/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/peter/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin:/home/peter/.espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin:/home/peter/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/bin:/home/peter/.espressif/tools/xtensa-esp-elf-gdb/12.1_20231023/xtensa-esp-elf-gdb/bin:/home/peter/.espressif/tools/riscv32-esp-elf-gdb/12.1_20231023/riscv32-esp-elf-gdb/bin:/home/peter/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/peter/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin:/home/peter/.espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin:/home/peter/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/bin:/home/peter/.espressif/python_env/idf5.2_py3.11_env/bin:/home/peter/data/tools/esp-idf/tools:/home/peter/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/peter/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/peter/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/peter/data/tools:/home/peter/data/tools/sdcc/bin:/home/peter/.yarn/bin:/home/peter/.config/yarn/global/node_modules/.bin:/home/peter/.nvm/versions/node/v18.18.0/bin:/home/peter/.rvm/gems/ruby-2.6.5/bin:/home/peter/.rvm/gems/ruby-2.6.5@global/bin:/home/peter/.rvm/rubies/ruby-2.6.5/bin:/home/peter/.local/bin:/home/peter/.cargo/bin:/home/peter/.local/bin:/home/peter/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/peter/Android/Sdk/emulator:/home/peter/Android/Sdk/platform-tools:/home/peter/Android/Sk/emulator:/home/peter/Android/Sk/platform-tools:/home/peter/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin:/home/peter/Dotfiles:/home/peter/.rvm/bin:/home/peter/.rvm/bin" PROJECT_DIR="/home/peter/data/code/esprs-test" SDKCONFIG_DEFAULTS="/home/peter/data/code/esprs-test/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-95e72fc75916bcbf/out/gen-sdkconfig.defaults;/home/peter/data/code/esprs-test/sdkconfig.defaults" "cmake" "/home/peter/data/code/esprs-test/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-95e72fc75916bcbf/out" "-G" "Ninja" "-DCMAKE_TOOLCHAIN_FILE=/home/peter/data/tools/esp-idf/tools/cmake/toolchain-esp32.cmake" "-DCMAKE_BUILD_TYPE=" "-DPYTHON=/home/peter/.espressif/python_env/idf5.2_py3.11_env/bin/python" "-DCMAKE_INSTALL_PREFIX=/home/peter/data/code/esprs-test/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-95e72fc75916bcbf/out" "-DCMAKE_C_FLAGS= -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections" "-DCMAKE_CXX_FLAGS= -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections" "-DCMAKE_ASM_FLAGS= -mlongcalls -ffunction-sections -fdata-sections"
  -- Configuring incomplete, errors occurred!

  --- stderr
  Build configuration: BuildConfig {
      esp_idf_tools_install_dir: None,
      esp_idf_sdkconfig: None,
      esp_idf_sdkconfig_defaults: None,
      mcu: Some(
          "esp32",
      ),
      native: NativeConfig {
          esp_idf_version: Some(
              Tag(
                  "v5.2",
              ),
          ),
          esp_idf_repository: None,
          esp_idf_cmake_generator: None,
          idf_path: Some(
              "/home/peter/data/tools/esp-idf",
          ),
          extra_components: [],
          esp_idf_components: None,
          esp_idf_component_manager: None,
      },
      esp_idf_sys_root_crate: None,
  }
  Using activated esp-idf v5.2.1 environment at '/home/peter/data/tools/esp-idf'
  CMake Error at /home/peter/data/tools/esp-idf/tools/cmake/project.cmake:506 (__project):
    Running

     '/home/peter/.local/bin/ninja' '--version'

    failed with:

     Traceback (most recent call last):
      File "/home/peter/.local/bin/ninja", line 5, in <module>
        from ninja import ninja

    ModuleNotFoundError: No module named 'ninja'

  Call Stack (most recent call first):
    CMakeLists.txt:28 (project)


  thread 'main' panicked at /home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5:

  command did not execute successfully, got: exit status: 1

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  • Would you like to work on a fix? y

To Reproduce

Steps to reproduce the behavior:

  1. cargo generate esp-rs/esp-idf-template cargo
  2. giv project name
  3. select esp32
  4. select no
  5. cd project
  6. cargo build

Environment

@SergioGasquez
Copy link
Member

See #188 (comment)

@PocketPi
Copy link
Author

PocketPi commented Apr 2, 2024

I Just installed v5.1 and it still doesnt work.

peter:~/data/code/esprs-test$ cargo build
   Compiling bindgen v0.63.0
   Compiling embuild v0.31.4
   Compiling esp-idf-sys v0.34.1
   Compiling esp-idf-hal v0.43.1
   Compiling esp-idf-svc v0.48.1
   Compiling esprs-test v0.1.0 (/home/peter/data/code/esprs-test)
The following warnings were emitted during compilation:

warning: [email protected]: Compiler version doesn't include clang or GCC: "cc" "--version"
warning: [email protected]: Compiler version doesn't include clang or GCC: "c++" "--version"

error: failed to run custom build command for `esp-idf-sys v0.34.1`

Caused by:
  process didn't exit successfully: `/home/peter/data/code/esprs-test/target/debug/build/esp-idf-sys-be56d55db34120ca/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=ESP_IDF_TOOLS_INSTALL_DIR
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG_DEFAULTS
  cargo:rerun-if-env-changed=MCU
  cargo:rerun-if-env-changed=ESP_IDF_SYS_ROOT_CRATE
  cargo:rerun-if-env-changed=ESP_IDF_VERSION
  cargo:rerun-if-env-changed=ESP_IDF_REPOSITORY
  cargo:rerun-if-env-changed=ESP_IDF_CMAKE_GENERATOR
  cargo:rerun-if-env-changed=IDF_PATH
  cargo:rerun-if-env-changed=EXTRA-COMPONENTS
  cargo:rerun-if-env-changed=ESP_IDF_COMPONENTS
  cargo:rerun-if-env-changed=ESP_IDF_COMPONENT_MANAGER
  cargo:rerun-if-changed=/home/peter/data/code/esprs-test/sdkconfig.defaults
  cargo:warning=Compiler version doesn't include clang or GCC: "cc" "--version"
  cargo:warning=Compiler version doesn't include clang or GCC: "c++" "--version"
  CMAKE_PREFIX_PATH_xtensa-esp32-espidf = None
  CMAKE_PREFIX_PATH_xtensa_esp32_espidf = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_xtensa-esp32-espidf = None
  CMAKE_xtensa_esp32_espidf = None
  TARGET_CMAKE = None
  CMAKE = None
  running: cd "/home/peter/data/code/esprs-test/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-95e72fc75916bcbf/out/build" && CMAKE_PREFIX_PATH="" EXTRA_COMPONENT_DIRS="" IDF_COMPONENT_MANAGER="1" IDF_PATH="/home/peter/data/tools/esp-idf-v5.1" IDF_TARGET="esp32" PATH="/home/peter/.rustup/toolchains/esp/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/home/peter/data/tools/esp-idf-v5.1/components/espcoredump:/home/peter/data/tools/esp-idf-v5.1/components/partition_table:/home/peter/data/tools/esp-idf-v5.1/components/app_update:/home/peter/.espressif/tools/xtensa-esp-elf-gdb/12.1_20221002/xtensa-esp-elf-gdb/bin:/home/peter/.espressif/tools/riscv32-esp-elf-gdb/12.1_20221002/riscv32-esp-elf-gdb/bin:/home/peter/.espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin:/home/peter/.espressif/tools/xtensa-esp32s2-elf/esp-12.2.0_20230208/xtensa-esp32s2-elf/bin:/home/peter/.espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin:/home/peter/.espressif/tools/riscv32-esp-elf/esp-12.2.0_20230208/riscv32-esp-elf/bin:/home/peter/.espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin:/home/peter/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230419/openocd-esp32/bin:/home/peter/.espressif/python_env/idf5.1_py3.11_env/bin:/home/peter/data/tools/esp-idf-v5.1/tools:/home/peter/data/tools:/home/peter/data/tools/sdcc/bin:/home/peter/.yarn/bin:/home/peter/.config/yarn/global/node_modules/.bin:/home/peter/.nvm/versions/node/v18.18.0/bin:/home/peter/.rvm/gems/ruby-2.6.5/bin:/home/peter/.rvm/gems/ruby-2.6.5@global/bin:/home/peter/.rvm/rubies/ruby-2.6.5/bin:/home/peter/.local/bin:/home/peter/.cargo/bin:/home/peter/.local/bin:/home/peter/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/peter/Android/Sdk/emulator:/home/peter/Android/Sdk/platform-tools:/home/peter/Android/Sk/emulator:/home/peter/Android/Sk/platform-tools:/home/peter/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin:/home/peter/Dotfiles:/home/peter/.rvm/bin:/home/peter/.rvm/bin" PROJECT_DIR="/home/peter/data/code/esprs-test" SDKCONFIG_DEFAULTS="/home/peter/data/code/esprs-test/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-95e72fc75916bcbf/out/gen-sdkconfig.defaults;/home/peter/data/code/esprs-test/sdkconfig.defaults" "cmake" "/home/peter/data/code/esprs-test/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-95e72fc75916bcbf/out" "-G" "Ninja" "-DCMAKE_TOOLCHAIN_FILE=/home/peter/data/tools/esp-idf-v5.1/tools/cmake/toolchain-esp32.cmake" "-DCMAKE_BUILD_TYPE=" "-DPYTHON=/home/peter/.espressif/python_env/idf5.1_py3.11_env/bin/python" "-DCMAKE_INSTALL_PREFIX=/home/peter/data/code/esprs-test/target/xtensa-esp32-espidf/debug/build/esp-idf-sys-95e72fc75916bcbf/out" "-DCMAKE_C_FLAGS= -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections" "-DCMAKE_CXX_FLAGS= -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections" "-DCMAKE_ASM_FLAGS= -mlongcalls -ffunction-sections -fdata-sections"
  -- Configuring incomplete, errors occurred!

  --- stderr
  Build configuration: BuildConfig {
      esp_idf_tools_install_dir: None,
      esp_idf_sdkconfig: None,
      esp_idf_sdkconfig_defaults: None,
      mcu: Some(
          "esp32",
      ),
      native: NativeConfig {
          esp_idf_version: Some(
              Tag(
                  "v5.1",
              ),
          ),
          esp_idf_repository: None,
          esp_idf_cmake_generator: None,
          idf_path: Some(
              "/home/peter/data/tools/esp-idf-v5.1",
          ),
          extra_components: [],
          esp_idf_components: None,
          esp_idf_component_manager: None,
      },
      esp_idf_sys_root_crate: None,
  }
  Using activated esp-idf v5.1.0 environment at '/home/peter/data/tools/esp-idf-v5.1'
  CMake Error at /home/peter/data/tools/esp-idf-v5.1/tools/cmake/project.cmake:365 (__project):
    Running

     '/home/peter/.local/bin/ninja' '--version'

    failed with:

     Traceback (most recent call last):
      File "/home/peter/.local/bin/ninja", line 5, in <module>
        from ninja import ninja

    ModuleNotFoundError: No module named 'ninja'

  Call Stack (most recent call first):
    CMakeLists.txt:28 (project)


  thread 'main' panicked at /home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5:

  command did not execute successfully, got: exit status: 1

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
``

@Vollbrecht
Copy link
Collaborator

esp-idf uses a specifc set of tools -> cmake, ninja, riscv-gcc , xtensa-gcc. When you install a specifc version of esp-idf via the python install scripts it also should install all this tools.

In a fully managed esp-idf repo ( auto installed by us if no activated esp-idf env found) we install this tools for you inside the .embuild dir for the respected esp-idf version.

It looks like your install is missing ninja so that's why it seams to fail.

You don't have this env variable set right?

@PocketPi PocketPi changed the title Project generated do not work with esp-idf v5.2.1 Project generated do not build when normal esp-idf environment is sourced Apr 2, 2024
@PocketPi
Copy link
Author

PocketPi commented Apr 2, 2024

So I have been digging some more,

It turned out the problem was that I was working in a terminal where i had already sourced the environment for a normal esp idf environment.

It would be great if the environments sourced would "deactivate" then other environment

@Vollbrecht
Copy link
Collaborator

Vollbrecht commented Apr 2, 2024

Technically it should be able to use the "other" sourced environment if it is setup with all the tools needed. The build script is activity trying to do so, but again in this case seams to stumble onto a maybe not fully installed ninja in your "other" environement?

@ivmarkov
Copy link
Collaborator

ivmarkov commented Apr 2, 2024

@PocketPi What is the OS and hardware of the host where you are compiling?

@PocketPi
Copy link
Author

ubuntu 23.10 and its an intel cpu

@Vollbrecht
Copy link
Collaborator

@PocketPi i think your the PATH variables emitted in your setup aren't quite right. Besides your activated sourced esp-idf install in "/home/peter/data/tools/esp-idf-v5.1" there are also traces for "/home/peter/.espressif/tools/", and last but not least the path to the ninja tool is even completely off as by default it should not check in "/home/peter/.local/bin/ninja". Did you manually install it there and then remove it or something?

Also be aware that esp-idf v5.1 is using gcc12 while v5.2 is using gcc13. So its crucial that your tools dir is clean.

@Vollbrecht
Copy link
Collaborator

closing this for now as i outlined what the problem was. In general we recommend to either only use exactly one external activated env, or use our managed installs.

Our managed installs don't permanently change env vars and so can't create this issues. And if you are using a single external activated env, through the official script the impact also should be limted.

In any case keep your env vars clean.

@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

4 participants