Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Node.js, PHP and APIs

Conan 2 cannot find the conanfile in a project that has one

Your error

ERROR: Conanfile not found at /home/dev/myproject/conanfile.py1 more line it can show

Fix it fast

Most common cause, 1 of 3

A recipe-only command was run on a conanfile.txt project

To fetch dependencies and build your own app, use conan install, then let CMake build with the generated toolchain.

Fix
conan install . --output-folder=build --build=missing
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build .
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Conan 2 prints "ERROR: Conanfile not found at <path>" when the exact file it looks for is missing. conan create, build, export and source accept only conanfile.py, so a project with just conanfile.txt fails. conan install also fails when its path argument, or the current folder, does not hold conanfile.txt. Use conan install . from the project root (Conan 2.34).

  • Applies to Conan 2.34.0, CMake toolchain flow (CMakeDeps, CMakeToolchain)
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Read the full path in the message and list that folder. A path ending in conanfile.py while your project has conanfile.txt is cause 1. A folder that is not your project root is cause 2. The right folder with a slightly different file name is cause 3.

Run this first
pwd
ls -la /home/dev/myproject

Then find the line you see in this list and open its fix:

  1. 1A recipe-only command was run on a conanfile.txt projectThe message ends in conanfile.py although the folder holds conanfile.txt, after conan create, conan build, conan export or conan source
  2. 2The path argument or the current folder is not the project rootThe path in the message is a build/ subfolder, a parent folder or a typo, and conanfile.txt sits somewhere else
  3. 3The file is named something other than conanfile.txtls shows Conanfile.txt, conanfile.txt.txt or conanfile.text in the right folder

What does the error look like?

  • ERROR: Conanfile not found at /home/dev/myproject/conanfile.py
  • ERROR: Conanfile not found at /home/dev/myproject/build/conanfile.txt

Cause 1 of 3

A recipe-only command was run on a conanfile.txt project

You seeThe message ends in conanfile.py although the folder holds conanfile.txt, after conan create, conan build, conan export or conan source

Check

Conanfile not found at .../conanfile.py appears because these commands ask Conan's local API for a Python recipe only. Conan's reference says conanfile.txt is meant for consuming dependencies and cannot be used to create a package, and the conan build page states that a .txt file is not accepted.

Check
ls conanfile.py conanfile.txt

Fix

To fetch dependencies and build your own app, use conan install, then let CMake build with the generated toolchain. Only write a conanfile.py when you need to create a package or run conan build.

Fix
conan install . --output-folder=build --build=missing
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build .

Verify

conan install lists the generators it ran, conan_toolchain.cmake appears in build/, and CMake configures without errors.

Verify
ls build/conan_toolchain.cmake

Confirmed by docs.conan.io

Did this fix it?

Cause 2 of 3

The path argument or the current folder is not the project root

You seeThe path in the message is a build/ subfolder, a parent folder or a typo, and conanfile.txt sits somewhere else

Check

Conan turns the path you pass into an absolute path from the current working directory, and conan install falls back to the current folder when you give no path. Running it from build/ makes Conan look for build/conanfile.txt, which does not exist.

Check
pwd && ls conanfile.*

Fix

Point the command at the folder that holds the file, or at the file itself. Both forms are accepted by conan install.

Fix
# from the build folder
conan install .. --output-folder=. --build=missing
# or name the file directly
conan install /home/dev/myproject/conanfile.txt --build=missing

Verify

The install output now names conanfile.txt from the project root and finishes with the generated files.

Verify
conan install .. --output-folder=. --build=missing

Confirmed by docs.conan.io

Did this fix it?

Cause 3 of 3

The file is named something other than conanfile.txt

You seels shows Conanfile.txt, conanfile.txt.txt or conanfile.text in the right folder

Check

When the path is a folder, Conan joins it with the exact names conanfile.py and conanfile.txt and checks that the file exists. A file saved by an editor with an extra extension, or with a capital C on a case-sensitive file system, is never matched.

Check
ls -1 | grep -i conanfile

Fix

Rename the file to the exact lowercase name, or pass the file's real name as the path argument.

Fix
mv conanfile.txt.txt conanfile.txt
conan install . --output-folder=build --build=missing

Verify

ls prints conanfile.txt and conan install starts resolving requirements.

Verify
ls conanfile.txt

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • Run Conan commands from the project root in scripts and CI, and pass an explicit path such as . instead of relying on the current folder.
  • Switch to a conanfile.py as soon as the project needs conan build, conan create or conditional requirements, which conanfile.txt cannot express.
  • Keep conanfile.txt under version control with its exact name, so a rename shows up in review.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.