Hello everybody, I was having a discussion with Mike McQuaid on https://github.com/mxcl/homebrew/issues/#issue/1905, about how to avoid breaking formulas when a keg_only dependency is updated and cleaned, and he asked me to continue it here. He claims that the solution is https://github.com/mxcl/homebrew/issues#issue/101, but I don't see how that solves this particular problem. Issue 101 seems to suggest using install_name_tool to change the install name of libraries from the keg to the install location, but this does not apply to keg_only formulas. dyld finds libraries by looking first in DYLD_LIBRARY_PATH, then at the install name recorded at link time, and finally in DYLD_FALLBACK_LIBRARY_PATH. Since keg_only formulas don't put things in the paths that are normally searched, what is needed is a stable installation location that won't change when the formula is upgraded. Currently we don't have that, because the installation prefix is Cellar/<formula>/<version>/. I propose a very simple solution: a symlink called Cellar/<formula>/current pointing to Cellar/<formula>/<latest version>. All we have to do it set up the paths to keg_only dependencies in install using Cellar/<formula>/current instead of Cellar/<formula>/<version>, and make sure that the libraries inside Cellar/<formula>/current have that path in their install name. The simplest solution, in my opinion, is this: when installing a keg_only formula, point the current symlink at the new version directory, then use Cellar/<formula>/current as the installation prefix. That way, libraries are built directly with the right (ie version-independent) install name. And this covers not only install paths, but every situation where the installation path is saved somewhere (such as pkg-config .pc files, which save the installation prefix). Thoughts? Happy new year, CL
On 1 January 2011 14:58, Camillo <camillo.lists@gmail.com> wrote: > Hello everybody, > I was having a discussion with Mike McQuaid > on https://github.com/mxcl/homebrew/issues/#issue/1905, about how to avoid > breaking formulas when a keg_only dependency is updated and cleaned, and he > asked me to continue it here. He claims that the solution > is https://github.com/mxcl/homebrew/issues#issue/101, but I don't see how > that solves this particular problem. Issue 101 seems to suggest using > install_name_tool to change the install name of libraries from the keg to > the install location, but this does not apply to keg_only formulas. > dyld finds libraries by looking first in DYLD_LIBRARY_PATH, then at the > install name recorded at link time, and finally in& > nbsp;DYLD_FALLBACK_LIBRARY_PATH. Since keg_only formulas don't put things in > the paths that are normally searched, what is needed is a stable > installation location that won't change when the formula is upgraded. Sorry, you misunderstood our intentions. We don't fix the formula paths but the paths of the things that link against them, changing the location and possible filename that's linked against. > Currently we don't have that, because the installation prefix is > Cellar/<formula>/<version>/. > I propose a very simple solution: a symlink called Cellar/<formula>/current > pointing to Cellar/<formula>/<latest version>. All we have to do it set up > the paths to keg_only dependencies in install using Cellar/<formula>/current > instead of Cellar/<formula>/<version>, and make sure that the libraries > inside Cellar/<formula>/current have that path in their install name. The > simplest solution, in my opinion, is this: when installing a keg_only > formula, point the current symlink at the new version directory, then > use Cellar/<formula>/current as the installation prefi x. That way, > libraries are built directly with the right (ie version-independent) install > name. And this covers not only install paths, but every situation where the > installation path is saved somewhere (such as pkg-config .pc files, which > save the installation prefix). pkg-config is another issue we need to work around but should also be fairly easy to fix (and is less of a problem than physical linking) and is yet to cause us any issues I'm aware of. The problem with the symlinks is it means you need to fix up all the commands to workaround them that expect the Cellar/formula/ to only contain versions. It's not a bad solution but it's one that changes Homebrew's approach to versioning fairly fundamentally. I had a similar idea but have since changed my mind. -- Mike McQuaid http://mikemcquaid.com
On 01/gen/2011, at 16.23, Mike McQuaid wrote: > On 1 January 2011 14:58, Camillo <camillo.lists@gmail.com> wrote: >> Hello everybody, >> I was having a discussion with Mike McQuaid >> on https://github.com/mxcl/homebrew/issues/#issue/1905, about how to avoid >> breaking formulas when a keg_only dependency is updated and cleaned, and he >> asked me to continue it here. He claims that the solution >> is https://github.com/mxcl/homebrew/issues#issue/101, but I don't see how >> that solves this particular problem. Issue 101 seems to suggest using >> install_name_tool to change the install name of libraries from the keg to >> the install location, but this does not apply to keg_only formulas. >> dyld finds libraries by looking first in DYLD_LIBRARY_PATH, then at the >> install name recorded at link time, and finally in& >> nbsp;DYLD_FALLBACK_LIBRARY_PATH. Since keg_only formulas don't put things in >> the paths that are normally searched, what is needed is a stable >> installation location that won't change when the formula is upgraded. > > Sorry, you misunderstood our intentions. We don't fix the formula > paths but the paths of the things that link against them, changing the > location and possible filename that's linked against. Ah, I see. Then that would work, but I'd prefer a solution where the install path is stable, so we don't have to go through all of the formula's users and change their load paths. BTW, it's not impossible that some people would use homebrew to install some libraries, possibly keg_only, and then manually link against them when building some other software that is not built using homebrew; in that case, we would have no idea that this program exists, and so we would be unable to fix it. The advantage of a stable install path is that everything works automatically. >> Currently we don't have that, because the installation prefix is >> Cellar/<formula>/<version>/. >> I propose a very simple solution: a symlink called Cellar/<formula>/current >> pointing to Cellar/<formula>/<latest version>. All we have to do it set up >> the paths to keg_only dependencies in install using Cellar/<formula>/current >> instead of Cellar/<formula>/<version>, and make sure that the libraries >> inside Cellar/<formula>/current have that path in their install name. The >> simplest solution, in my opinion, is this: when installing a keg_only >> formula, point the current symlink at the new version directory, then >> use Cellar/<formula>/current as the installation prefi x. That way, >> libraries are built directly with the right (ie version-independent) install >> name. And this covers not only install paths, but every situation where the >> installation path is saved somewhere (such as pkg-config .pc files, which >> save the installation prefix). > > pkg-config is another issue we need to work around but should also be > fairly easy to fix (and is less of a problem than physical linking) > and is yet to cause us any issues I'm aware of. > > The problem with the symlinks is it means you need to fix up all the > commands to workaround them that expect the Cellar/formula/ to only > contain versions. Oh, I suggested using Cellar/<formula>/current for tidyness, but it doesn't have to be inside $prefix/Cellar. We could use, eg, $prefix/share/homebrew/keg_only/<formula>, or $prefix/keg_only/<formula>, or even a new term with a beer-related name that I cannot think of at the moment. Alternatively, I can volunteer to fix up all the commands. > It's not a bad solution but it's one that changes Homebrew's approach > to versioning fairly fundamentally. I had a similar idea but have > since changed my mind. Would using a prefix outside of Cellar reduce the impact sufficiently? CL