gobolinux / Scripts

The GoboLinux scripts collection
41 stars 9 forks source link

inconsistent behavior on version resolution by `FindDependencies` #39

Closed Nuc1eoN closed 2 years ago

Nuc1eoN commented 2 years ago

I have observed some oddities with FindDependencies which is being used by Runner and thus also by Compile.

To follow create the following scenario:

You have a program called Dummy under /Programs with the following versions:

ls /Programs/Dummy
1.5 1.6 1.12 1.13

You can follow along by recreating this file system structure on your system.

Now create a Dependencies file in your home dir with the following content:

Dummy > 1.5

Now run FindDependencies on that file:

FindDependencies Dependencies

The expected result is 1.13 right? However the actual result is:

/Programs/Dummy/1.6

Obviously wrong! The first guess here is that FindDependencies sees 1.6 > 1.13, right? One might guess it is due to the double digits!

However if so, how does the following make any sense: Now put Dummy > 1.6 into your Dependencies file. Now FindDependencies has the following result:

/Programs/Dummy/1.13

Bollocks! So suddenly FindDependencies resolves 1.6 < 1.13!

I struggle to understand what is going on here.

hishamhm commented 2 years ago

I haven't looked at the code, but my guess is that all that FindDependencies reads the Dummy directory and returns some entry that matches (reading the directory in filesystem (i.e. random) order), rather than the best one. If that is the case, for detecting whether a dependency is missing or not, that behavior would be sufficient — but for use with Runner, probably not ideal as it would potentially link with older libraries when newer ones are installed.

Some C debugging of FindDependencies.c would explain what's going on.

Nuc1eoN commented 2 years ago

but for use with Runner, probably not ideal as it would potentially link with older libraries when newer ones are installed.

Yes absolutely, especially since Runner is used by Compile internally.

So if you are in installing a new program with Compile, it will potentially link the wrong dependency version in the build process, potentially leading to a failed build. This is exactly what happened for me and it took me some time and effort to finally nail it down to Runner and eventually FindDependencies.

lucasvr commented 2 years ago

Yep, that's a bug. I'm pushing a fix now -- thanks for the heads up!

Nuc1eoN commented 2 years ago

@lucasvr Thanks a lot, that fixed it!

PS: In case you have forgot, please look into irc chat. I have sent you a message (10 days ago^^).