Conan 2 cannot find the conanfile in a project that has one
Fix it fast
Most common cause, 1 of 3A 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.
conan install . --output-folder=build --build=missing
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build .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).
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.
pwd
ls -la /home/dev/myprojectThen find the line you see in this list and open its fix:
- 1A recipe-only command was run on a conanfile.txt project
The message ends in conanfile.py although the folder holds conanfile.txt, after conan create, conan build, conan export or conan source - 2The path argument or the current folder is not the project root
The path in the message is a build/ subfolder, a parent folder or a typo, and conanfile.txt sits somewhere else - 3The file is named something other than conanfile.txt
ls 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.pyERROR: 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.
ls conanfile.py conanfile.txtFix
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.
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.
ls build/conan_toolchain.cmakeConfirmed by docs.conan.io
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.
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.
# from the build folder
conan install .. --output-folder=. --build=missing
# or name the file directly
conan install /home/dev/myproject/conanfile.txt --build=missingVerify
The install output now names conanfile.txt from the project root and finishes with the generated files.
conan install .. --output-folder=. --build=missingConfirmed by docs.conan.io
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.
ls -1 | grep -i conanfileFix
Rename the file to the exact lowercase name, or pass the file's real name as the path argument.
mv conanfile.txt.txt conanfile.txt
conan install . --output-folder=build --build=missingVerify
ls prints conanfile.txt and conan install starts resolving requirements.
ls conanfile.txtConfirmed by raw.githubusercontent.com
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.