-
Notifications
You must be signed in to change notification settings - Fork 214
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
How can you get a library's output path from bxl? #528
Comments
CC @wendy728 (I have no idea) |
Have you tried I will add a some docs about that method since people have a hard time finding it in our generated docs, and also work on improving the error message for As for the restrictions on ensured artifact, yes the API is intentionally restrictive so that people don't accidentally use the paths as strings, which might break in actions ran remotely, for example. See more. here. |
I’ll try this. Is there any reason it would be a bad idea for I think what’s difficult about finding this function is that it doesn’t really make sense as a global. There’s already ctx.fs with similar methods. Or why not just as a member function on the artifact itself? These are the natural places one would expect to find such a method |
The functions available on |
In that case, how about a method on the artifact object? I tried I actually have a local patch that adds this method to output artifact, im just wondering if it’s worth trying to upstream or if it will be seen as making it too easy to do unsafe things. I understand the desire to make it difficult to shoot yourself in the foot by doing unsafe things, but at the same time one of the primary motivating use cases of bxl (IDE project generation) has heavy reliance on these kinds of unsafe operations. |
The issue is that the artifact type is shared between normal rules and BXL. We could probably get it to only be exposed in BXL, but I would have to do some investigation on how to implement it correctly, but also that could be confusing if an object method is only available in BXL vs rules. |
Just my own 2c, but I think bxl is a natural place for methods which are really unsafe for rules but quite natural when you want to introspect. IDE project generation, for example, often relies on absolute paths, but you’d never want to use an absolute path in a rule. So bxl should make it easy to get absolute paths for all kinds of things. |
I want the equivalent of
buck2 targets root//:foo --show-output
but implemented from bxl.Things I tried:
Assume that in all of the following cases, I have
output = ctx.analysis(target).providers()[DefaultInfo].default_outputs[0]
output
: This gives is anartifact
object, but there appears to be no way (that I can find anyway) to get the path of that artifact in the output directory.ctx.output.ensure(output)
: That returns anensured_artifact
which haveabs_path()
andrel_path()
methods, but those methods dont' return strings, they just appear to return the originalensured_artifact
. Besides, I don't actually want to build them, I just want their paths (similar to whatbuck2 targets --show-output
does).ctx.fs.abs_path_unsafe(output)
. I get the unusual error:which is complaining the expected type (
artifact
) and actual type (artifact
) don't match.Anything else I can try?
The text was updated successfully, but these errors were encountered: