-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix pkg-config quoting behavior #1842
Conversation
f3c9b8f
to
8760fa4
Compare
To reiterate the arguments against any kind of homebrew support:
The root of the problem is that we'd like dune to look for external libraries in places that the user has not specified explicitly. I'm not sure it's such a good idea to do this by default, and if it's done at all, it should clearly be more flexible than we have now |
The last commit removes the homebrew magic, which is admittedly a breaking change and not something we can just do. A more backwards compatible way to proceed would be to leave the homebrew stuff intact, and parse the |
c7cec74
to
4711c30
Compare
Okay, so I implemented the workaround mentioned above. It's not very attractive but should do the job. For dropping the brew support, perhaps we should finally introduce that V2 API. The API would be the same, but only V1 would use brew. I'm not such a fan of this idea, but I don't think we should break user packages. |
src/configurator/v1.ml
Outdated
| init :: xs -> | ||
let pos = List.fold_left ~init ~f:min xs in | ||
String.trim (String.take package pos) | ||
in | ||
[sprintf "PKG_CONFIG_PATH=$PKG_CONFIG_PATH:%s/opt/%s/lib/pkgconfig" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to construct %s/opt/%s/lib/pkgconfig
and quote it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quoting the environment is a good idea (Although I have a better fix for that coming up), but I don't think it would fix the issue. The ~package
contains a pkg-config query which contains more than just name + version. So it wouldn't work to include it in the path.
10f7318
to
d66e721
Compare
Another possibility would be to add another function for our pkg-config API that would take the package name and the version query separately. |
I've pushed a commit that avoids all env/quoting issues for pkg-config by avoiding the shell in the first place. We could extend its usage in other places, but there's no immediate need. It also seems like we should just extract this code and share it in our As for the querying issue, @ejgallego I think the best course of action to fix the v1 API is to an optional argument. Roughly:
In the V2 API, we'll get rid of this homebrew support altogether. |
I am very far from an expert on Also this seems better to keep compatibility in V1. |
It certainly doesn't seem right to me either. But to "fix" the current homebrew behavior, we need to know the package name. Otherwise, we will not know how to append the How about:
where you provide the full expression |
@rgrinberg wrote:
I agree with this entirely. But we have to bear in mind that macOS developers form the majority of our desktop-dev users, and we should try to make things work out of the box. Some mechanism for Dune to centrally specify a search mechanism that could be tailored for the local package manager in one place would be extremely useful to have. Homebrew is very predictable in where it places libraries -- it's just different from all the other package managers. |
I'm afraid I don't know the necessary details to contribute a lot more here :( I am just wondering why we cannot restore the old behavior, which so far used to work fine, didn't it? |
The old behavior worked, but our homebrew support was still broken. By default, homebrew's pkg-config will indeed list most packages (which includes the gtk family of packages), so no homebrew specific hacks are necessary. However, if you tried doing that kind of expression with openssl for example, it would be broken again. |
Note that the issue isn't with homebrew in general, but only a few select packages that are "keg only" - openssl being the most prominent example. I think it's acceptable that these packages will take on these hacks rather than configurator. |
I see, thanks for the explanation @rgrinberg |
Looking at this discussion, I suggest the following changes:
with this plan, existing packages won't be affected. Packages using configurator to query keg-only pkg-config packages will have to upgrade to |
Isn't it |
Indeed. I don't have a better suggestion though |
1c04313
to
4cc4218
Compare
I've added a |
c6c9b04
to
8aabc1b
Compare
@diml this is ready for review |
let stdout = openfile stdout_fn in | ||
let stderr = openfile stderr_fn in | ||
let (stdin, stdin_w) = Unix.pipe () in | ||
Unix.close stdin_w; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No objection here, but note that we don't do this for processes started by dune
Thanks @rgrinberg , I've launched a build with this branch here: it seems to work ! And this is one where I am using the new API: one build fails due to missing OPAM constraint on |
70972e8
to
8ee0fbc
Compare
Shows that on OSX (whenever brew is present), things are not being quoted correctly. Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Running it directly avoids issues with quoting and environment handling Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
For more complex pkg config queries Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
8ee0fbc
to
666b6b6
Compare
CHANGES: - Add `${corrected-suffix}`, `${library-name}` and a few other variables to the list of variables to upgrade. This fixes the support for various framework producing corrections (ocaml/dune#1840, ocaml/dune#1853, @diml) - Fix `$ dune subst` failing because the build directory wasn't set. (ocaml/dune#1854, fix ocaml/dune#1846, @rgrinberg) - Configurator: Add warning to `Pkg_config.query` when a full package expression is used. Add `Pkg_config.query_expr` for cases when the full power of pkg-config's querying is needed (ocaml/dune#1842, fix ocaml/dune#1833, @rgrinberg) - Fix unavailable, optional implementations eagerly breaking the build (ocaml/dune#1857, fix ocaml/dune#1856, @rgrinberg)
Shows that on OSX (whenever brew is present), things are not being quoted correctly. This is another incentive for us to drop the builtin homebrew support we have in configurator (cc @avsm, @ejgallego, and @andreypopp)