How to purge an unused old provider in a lock file

Hello, I am using Terraform For Github with terraform-github-provider and I saw the below message when I executed terraform init -upgrade.

Warning: Additional provider information from registry

The remote registry returned warnings for

  • For users on Terraform 0.13 or greater, this provider has moved to
    integrations/github. Please update your source in required_providers.

So I had replaced it in my required_providers clause and executed terraform init -upgrade.

 required_providers {
   github = {
-    source  = "terraform/github"
+    source  = "integrations/github"
     version = "~> 4.0"

But the .terraform.lock.hcl file seems still contains the information about both the old and new providers.

# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.

provider "" {
  version     = "4.5.2"
  constraints = "~> 4.0"
  hashes = [

provider "" {
  version     = "4.6.0"
  constraints = "~> 4.0"
  hashes = [

How to purge old unused ‘terraform/github’ provider in a way other than a manual deleting these lines? I tried terraform init -reconfigure -upgrade but nothing happens.

Additional info:

$ terraform version
Terraform v0.14.8
+ provider v4.5.2
+ provider v4.6.0
$terraform providers

Providers required by configuration:
└── provider[] ~> 4.0

Providers required by state:


Best regards.

Hi @lens0021,

There isn’t an automatic way to purge it, because Terraform is trying to keep hold of these previously-learned hashes in case you removed the provider in error and want to add it back again.

However, if you know you will no longer be using the provider at its old address, it would be safe to edit the file and delete the corresponding block.

Terraform doesn’t make use of the information in the lock file unless the provider installation process determines that it needs to install a particular provider that’s already recorded in there, so that extra entry won’t affect Terraform’s behavior in any significant way unless you were to re-add the old address to your configuration later, although as you saw terraform version does happen to use it to produce its extra information about which specific providers are selected, which is a cosmetic thing only.

I am happy for hearing that. Thanks!