# No such file or directory @ realpath_rec



## ishtar (Apr 30, 2018)

Hello,

Been having this issue and cant seem to figure out how to fix it. I've seen this thread but clearing 
	
	



```
/usr/local/lib/compat/pkg
```
 doesn't resolve the issue. For example, I just emptied it, used portupgrade to update dehydrated, and after it's completed I get the following:

```
===>  Cleaning for dehydrated-0.6.2_1
--->  Cleaning out obsolete shared libraries
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/libXaw7.so.7
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/libmysqlclient.so.20
```

Any idea how to get rid of these?

Thank you


----------



## ShelLuser (May 1, 2018)

What _exact_ command(s) did you use to upgrade?  Also: have you been mixing ports and packages perhaps? So, at one moment you run `pkg install <stuff>` while in the other you're using portupgrade?


----------



## ishtar (May 2, 2018)

Thanks for the reply. Today I ran the following:
`portupgrade -rRf vlc`

Once it was done, I could see:

```
--->  Cleaning out obsolete shared libraries
No such file or directory @ realpath_rec - /usr/local/lib/libXaw7.so.7.0.0
No such file or directory @ realpath_rec - /usr/local/lib/libXaw7.so.7.0.0
No such file or directory @ realpath_rec - /usr/local/lib/mysql/libmysqlclient.so.20
```

I even tried to symlink the files to that directory, but the link appears to vanish during the process somewhere.

As far as I know, I haven't (even accidentally) installed any packages using the pkg utility. Is there a way to trace that?


Edit:
Last night, I ran the following: `portupgrade -frR apache24 freetype2`

And got the following:

```
No such file or directory @ realpath_rec - /usr/local/lib/libvpx.so.5.0.0
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/libXaw6.so.6
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/libXaw7.so.7.0.0
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/libXaw7.so.7.0.0
No such file or directory @ realpath_rec - /usr/local/lib/mysql/libmysqlclient.so.20
```


----------



## ishtar (May 9, 2018)

Bump? Can anyone help?


----------



## trev (Jun 8, 2018)

ishtar said:


> Bump? Can anyone help?



Maybe, I had the same problem on my rpi2:


```
===>  Cleaning for ca_root_nss-3.37.3
--->  Cleaning out obsolete shared libraries
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5/libdb-5.3.so.0
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5/libdb_cxx-5.3.so.0
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5/libdb_stl-5.3.so.0
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5/libdb-5.3.so.0
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5/libdb_cxx-5.3.so.0
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5/libdb_stl-5.3.so.0
```

I tried deleting db5 and reinstalling, to no effect.

The library files listed above are not in the db5 directory, but the directory above that. I deleted the files from /usr/local/lib/compat/pkg and all was well.

Have you checked your /usr/local/lib/compat/pkg/ directory?


----------



## ishtar (Jun 8, 2018)

Thanks, but that's the first thing I tried. Deleted the entire /usr/local/lib/compat/pkg directory but the problem remains.


----------



## trev (Jun 9, 2018)

Let me get this right. You deleted /usr/local/lib/compat/pkg and you are still getting messages referring to that directory even though it doesn't exist?

My only other suggestion is to find one of the files being referred to and delete it (or maybe just rename it until you are certain there are no unexpected consequences). That's how I found the files in my case which were not in the directory being complained about, but the directory above.


----------



## ishtar (Jun 12, 2018)

Well I had other ports-related issues and decided to just reinstall everything.

I deleted /usr/ports/
Looped through `pkg` to uninstall everything
Then wiped /var/db/pkg
And finally reinstalled ports I needed.

Everything is solved now. Whatever it was, I know the actions taken were drastic, but the end result is the issue is no longer happening.

Edit: Spoke too soon. Updated pkg, and the problem is back.


```
===>  Cleaning for pkg-1.10.5_1
--->  Cleaning out obsolete shared libraries
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/gcc49
```

So I'm 100% sure the problem is the pkg package. No clue what to do anymore.


----------



## SirDice (Jun 13, 2018)

ishtar said:


> Looped through  pkg to uninstall everything


Err, `pkg delete -af`


----------



## Bubrak (Aug 13, 2018)

Hi, 

I have same issue, dont know what to do and cannot find any solution on internet. After each usage of portupgrade it finishes with this, and in time it is getting longer and longer. At first there was just the last line with libmysqlclient.so.20, but now there are 9 lines after some period (maybe 4-5 months ago it started to do this).


```
===>  Cleaning for jpeg-turbo-2.0.0
--->  Cleaning out obsolete shared libraries
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/libXaw6.so.6.0.1
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/libXaw7.so.7.0.0
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/db5
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/libmysqlclient.so.20
```

Thank you for any help.


----------



## trev (Aug 14, 2018)

```
/usr/local/lib/compat/pkg/
```

As I understand it, this directory holds "old" libraries some of which may be in use by a port or ports which you have installed but not updated. `pkg` moves those "old" libraries here so that a port/ports may still find them and work.

So long as you recompile your ports AND their dependancies (both those which rely on the port AND those which are required by the port) , you can safely delete the libraries in this directory.

I don't understand why `pkg` started having this issue though as it never used to occur.


----------



## Bubrak (Aug 14, 2018)

Hi Trev,

thank you for some ideas. I've found also that in that directory are soft links with non existent targets and that may be the issue.

i.e. libmysqlclient_r.so.20 -> libmysqlclient.so.20 which should be causing this line:

```
No such file or directory @ realpath_rec - /usr/local/lib/compat/pkg/libmysqlclient.so.20
```
as libmysqlclient.so.20 is not present

there are also several links to db5/<something> when folder db5 is not present

I deleted link libmysqlclient_r.so.20 -> libmysqlclient.so.20 and will see what will happen in next portupgrade usage.

But anyway still there is the issue about creating these incorrect links.

Thank you, best regards


----------



## Bubrak (Aug 16, 2018)

Hi all,

so after deleting all links with missing targets, portupgrade is not writing those lines anymore.

But still there remains issue with pkg which creates these links or deletes targets of these links with no cleanup after that. Will track this behaviour further.

Code to delete all corrupted links here: 

```
# change folder
cd /usr/local/lib/compat/pkg
# print dangling links
find . -type l -exec test ! -e {} \; -print
# delete dangling links
find . -type l -exec test ! -e {} \; -delete
```

Thanks, best regards


----------



## trev (Aug 20, 2018)

I suspect the issue is pkg creates the soft links, but portupgrade deletes the library files and knows nothing about pkg and its soft links and so doesn't clean them up. Might have to lodge a PR against portupgrade to get it to check in /usr/local/lib/compat/pkg/. Or write a script to check the soft links and delete if no file found. Hmmm.


----------



## jrronimo (Oct 3, 2018)

Bubrak said:


> Hi all,
> 
> so after deleting all links with missing targets, portupgrade is not writing those lines anymore.
> 
> ...



I ran into this problem recently as well -- that little script seems to have fixed it though. Thanks!


----------



## allan_sundry (Oct 1, 2019)

Yep, it works. Thanks!


----------



## VASYL MELNYK (Dec 29, 2019)

Th!
one line command
find /usr/local/lib/compat/pkg/ -type l -exec test ! -e {} \; -delete


----------

