-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
File#short_path in Skylark is not resolvable from its root #1462
Comments
I can confirm that this is a difference between the documentation and the implementation. Assigning to @kchodorow to determine whether the bug is in the implementation or documentation. |
Well, the goal is to have .path also return ../com_github_golang_glog. bdfd58a did this (which was rolled back, but I'm hoping to send a code review to roll it forward today). So, it's kind of going to go in the other direction: path is going to be updated to match short_path. For now, can the go rule just use path, if they aren't trying to reference runfiles? |
Implement the old behavior of File.short_path by myself
I've added a short-term workaround in rules_go. But IIUC, your change makes this workaround also broken because it still depends on that What is the recommended way to get paths to files in execRoot when I build command line arguments in Skylark actions? |
.path should still work, it'll just be a different path than it is now. |
@kchodorow Ah, I understand. I should have read the commit message of bdfd58a. |
So, problem is actual to me. I am writing repository with rules for python (with virtualenv support) In my rules I am generating the executable shell script, which make
If I generate script using "virtualenv.short_path" and "python_file.short_path" every rule from repository which uses my rules_python works fine. If I generate script using "virtualenv.path" and "python.path" rule from my rules_python works fine, while rules from repository which uses my rules_python broken. What the correct way to reference to some dependencies file in my scripts independent from location - primary repo or external? |
The behavior of
short_path
method ofFile
type in Skylark has changed in Bazel 0.3.0.Although it looks to be related to the runfiles structure change, I doubt if this change of
short_path
was intentional because the new behavior looks to be different from its documentation.short_path
of a File in an external repository used to return a relative path from$(SRCDIR)
in Bazel 0.2.3, but now it looks to be returning a runtime relative path in the new runfiles structure.How to reproduce
Put the following files
WORKSPACE
,BUILD
andexample.bzl
into a directory.WORKSPACE
:BUILD
:# empty
example.bzl
:Then,
bazel build @com_github_golang_glog//:readme
Expected result
I expected the following result, which is same as the actual result in Bazel 0.2.3.
Actual result
For me the old behavior looks to be more appropriate because the documentation says
So I expect that
short_path
is equivalent topath
if I resolve it fromroot.path
.Although it also says
But the example above shows that these two definitions do not match to each other.
Proposal
At the same time, I understand that relative path in runfiles is also important for rule developers.
So I propose distinguishing
short_path
from runfiles mapping as the followings.short_path
.short_path
runtime_path
, which returns a relative path to the file in the runfiles structure.References
This behavior change is the root cause of an issue of
rules_go
, bazel-contrib/rules_go#35 (comment).The text was updated successfully, but these errors were encountered: