{"record":{"id":"6228ff7f268e406a","repo":"hashicorp/vagrant","slug":"the-requested-vagrant-action-is-locked-this-may-b","errorCode":null,"errorMessage":"The requested Vagrant action is locked. This may be caused\nby other Vagrant processes attempting to do a similar action.\n\nLock file path: %{lock_file_path}","messagePattern":"The requested Vagrant action is locked\\. This may be caused\nby other Vagrant processes attempting to do a similar action\\.\n\nLock file path: %(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::VagrantLocked","httpStatus":null,"severity":"error","filePath":"lib/vagrant/util/file_mutex.rb","lineNumber":31,"sourceCode":"      end\n\n      # Execute provided block within lock and unlock\n      # when completed\n      def with_lock(&block)\n        lock\n        begin\n          block.call\n        rescue => e\n          raise e\n        ensure\n          unlock\n        end\n      end\n\n      # Attempt to acquire the lock\n      def lock\n        if lock_file.flock(File::LOCK_EX|File::LOCK_NB) === false\n          raise Errors::VagrantLocked, lock_file_path: @mutex_path\n        end\n      end\n\n      # Unlock the file\n      def unlock\n        lock_file.flock(File::LOCK_UN)\n        lock_file.close\n        File.delete(@mutex_path) if File.file?(@mutex_path)\n      end\n\n      protected\n\n      def lock_file\n        return @lock_file if @lock_file && !@lock_file.closed?\n        @lock_file = File.open(@mutex_path, \"w+\")\n      end\n    end\n  end","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/lib/vagrant/util/file_mutex.rb#L13-L49","documentation":"Vagrant::Util::FileMutex#lock calls flock(File::LOCK_EX | File::LOCK_NB) on the mutex file; when the non-blocking exclusive lock cannot be granted (flock returns false because another process holds it) it raises VagrantLocked with the lock file path. Vagrant serializes environment/machine actions this way, so the error means another live Vagrant process is mid-action on the same target.","triggerScenarios":"Two Vagrant commands racing on the same project/environment — `vagrant up` in one terminal while `vagrant reload`/`halt` runs in another; an IDE plugin or background daemon invoking vagrant concurrently with your shell.","commonSituations":"Overlapping automation scripts without serialization; a previous vagrant process that hung while still holding the flock; CI jobs sharing one checkout.","solutions":["Wait for the in-flight Vagrant command to finish, then re-run","Find the holder via `lsof <lock_file_path>` (or fuser -v) and kill it only if it is genuinely hung","Serialize access in tooling (queue, flock wrapper, make) so two vagrant invocations never overlap on one environment"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"def lock_held?(path)\n  return false unless File.exist?(path)\n  f = File.open(path, 'a+')\n  got = f.flock(File::LOCK_EX | File::LOCK_NB)\n  f.flock(File::LOCK_UN) unless got == false\n  f.close\n  got == false\nend\n\nsleep until !lock_held?(mutex_path)","typeGuard":null,"tryCatchPattern":"tries = 0\nbegin\n  mutex.with_lock { do_work }\nrescue Vagrant::Errors::VagrantLocked\n  tries += 1\n  sleep 2**tries\n  retry if tries < 5\nend","preventionTips":["Serialize concurrent vagrant automation with your own flock/queue","Never share one Vagrant environment between simultaneous jobs","Kill hung vagrant processes before re-running"],"tags":["lock","concurrency","mutex","flock"],"backgroundTag":"file-lock-held","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}