{"record":{"id":"a5ee904d508e3187","repo":"hashicorp/vagrant","slug":"vagrant-provisioners-ansible-cannot-detect","errorCode":null,"errorMessage":"vagrant.provisioners.ansible.cannot_detect","messagePattern":"vagrant\\.provisioners\\.ansible\\.cannot_detect","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/provisioners/ansible/provisioner/guest.rb","lineNumber":51,"sourceCode":"        # The compatibility mode checks are also performed here in order to fetch the\n        # Ansible version information only once.\n        #\n        # Current limitations:\n        #   - The installation of a specific Ansible version is only supported by\n        #     the \"pip\" install_mode. Note that \"pip\" installation also takes place\n        #     via a default command. If pip needs to be installed differently then\n        #     the command can be overwritten by supplying \"pip_install_cmd\" in the\n        #     config settings.\n        #   - There is no absolute guarantee that the automated installation will replace\n        #     a previous Ansible installation (although it works fine in many cases)\n        #\n        def check_and_install_ansible\n          @logger.info(\"Checking for Ansible installation...\")\n\n          # If the guest cannot check if Ansible is installed,\n          # print a warning and try to continue without any installation attempt...\n          if !@machine.guest.capability?(:ansible_installed)\n            @machine.ui.warn(I18n.t(\"vagrant.provisioners.ansible.cannot_detect\"))\n            return\n          end\n\n          # Try to install Ansible (if needed and requested)\n          if config.install &&\n             (config.version.to_s.to_sym == :latest ||\n              !@machine.guest.capability(:ansible_installed, config.version))\n            @machine.ui.detail I18n.t(\"vagrant.provisioners.ansible.installing\")\n            @machine.guest.capability(:ansible_install, config.install_mode, config.version, config.pip_args, config.pip_install_cmd)\n          end\n\n          # This step will also fetch the Ansible version data into related instance variables\n          set_and_check_compatibility_mode\n\n          # Check if requested ansible version is available\n          if (!config.version.empty? &&\n              config.version.to_s.to_sym != :latest &&\n              config.version != @gathered_version)","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/provisioners/ansible/provisioner/guest.rb#L33-L69","documentation":"Error \"vagrant.provisioners.ansible.cannot_detect\" thrown in hashicorp/vagrant.","triggerScenarios":"Thrown at plugins/provisioners/ansible/provisioner/guest.rb:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}