# How do I delete a package from the system leaving the installed files in place



## scotia (Nov 11, 2020)

Hi,

I installed package "foo" and later starting using the upstream of "foo" to upgrade it rather than wait for ports to catch up.

How can I remove the "foo" package without actually deleting the files (that have since been upgraded manually)?

I want to do this lest I downgrade doing a ports rebuild after a major OS version update.

Many thanks in advance,
Scott


----------



## scottro (Nov 11, 2020)

If I understand your question then 
	
	



```
pkg delete -f foo
```
 will remove foo and leave all other packages. I'm guessing you mean that you find that pkg delete foo will also remove several other packages that depend upon it.

Another Scott


----------



## scotia (Nov 11, 2020)

Hi,

no - I want to leave the files that were installed as part of "foo" intact (let's say it has no dependencies).  I just want to remove "foo" from the package database.

Thanks


----------



## rawthey (Nov 11, 2020)

Hi,


scotia said:


> I installed package "foo" and later starting using the upstream of "foo" to upgrade it rather than wait for ports to catch up.
> 
> How can I remove the "foo" package without actually deleting the files (that have since been upgraded manually)?
> 
> ...


You could prevent it from being altered by the package system with `pkg lock foo`


----------



## scotia (Nov 11, 2020)

Cool.  Will locking make it immune to `portmaster -af`?

Thanks


----------



## rawthey (Nov 11, 2020)

scotia said:


> Cool.  Will locking make it immune to `portmaster -af`?
> 
> Thanks


It should do. I've sometimes forgot to unlock a package and had portmaster fail at the install stage


----------



## Lamia (Nov 11, 2020)

Yes, it will. You shall be asked at the time of upgrade via postmaster if you want to unlock and upgrade it.


----------



## ShelLuser (Nov 11, 2020)

This looks like a recipe for disaster to me, depending on the package. Why not remove the package (and its files), re-install your updated version somewhere and leave things there until the package catches up?


----------



## scotia (Nov 11, 2020)

ShelLuser said:


> Why not remove the package


It has no dependencies nor is it a dependency and rather than stopping the service, deleting the package, reinstalling from upstream, restarting the service - I thought I'd ask if I could just remove the package from the DB.
In this case there's no disaster caused by doing so (that I can see).  The system would just forget it's still there.


----------

