Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Buck parses build files in buck-out #527

Closed
davido opened this issue Nov 24, 2015 · 5 comments
Closed

Buck parses build files in buck-out #527

davido opened this issue Nov 24, 2015 · 5 comments

Comments

@davido
Copy link
Contributor

davido commented Nov 24, 2015

Trying to upgrade Buck to recent master: [1] reveals that buck test is inherently broken. It interferes with Eclipse output directory (written to buck-out/eclipse) with errors like:

$ buck test --include api
[-] PARSING BUCK FILES...FINISHED 1,0s
BUILD FAILED: //buck-out/eclipse/test/com/google/gerrit/acceptance/server/project:server-project-flaky: parameter 'srcs': no such file or directory 'buck-out/eclipse/test/com/google/gerrit/acceptance/server/project/ProjectWatchIT.java'

Note, that we are using Eclipse and telling it to use buck-out/eclipse as output drectory:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" output="buck-out/eclipse/test" path="gerrit-acceptance-framework/src/test/java"/>
    <classpathentry kind="src" output="buck-out/eclipse/test" path="gerrit-acceptance-tests/src/test/java"/>

So Eclipse is copying all files (except *.java) to this directory:

$ ls -1 buck-out/eclipse/test/com/google/gerrit/acceptance/server/project/
BUCK
CustomLabelIT.class
LabelTypeIT.class
ProjectWatchIT.class

My impression is that Buck is trying to parse Buck files from this output directory.
I've tracked down the problem to this commit:

35cb495 is the first bad commit

Steps to reproduce:

  1. clone most recent Gerrit master: git clone https://gerrit.googlesource.com/gerrit
  2. replace Buck version with 35cb495 in .buckversion
  3. run buck test --include api -> all is fine
  4. generate Eclipse project files with: tools/eclipse/project.py
  5. start Eclipse, import gerrit project, refresh gerrit project in Eclipse to force building to buck-out/eclipse
  6. run buck test --include api is failing with error mentioned above

[1] https://gerrit-review.googlesource.com/72682

@davido davido changed the title buck test intereferes with output files written by Eclipse buck test interferes with output files written by Eclipse Nov 24, 2015
@Coneko
Copy link

Coneko commented Nov 24, 2015

You shouldn't be writing or modifying files in buck-out, it will cause problems in general.

Can you change your eclipse project to output to a directory that isn't in buck-out?

It's pretty silly of Buck to be parsing build files in there though.

@davido
Copy link
Contributor Author

davido commented Nov 24, 2015

We could probably introduce eclipse-outfor that, yes.

@davido
Copy link
Contributor Author

davido commented Nov 25, 2015

Moving Eclipse output from buck-out fixed it. However, I figured out, that Buck even interferes with itself. All you need to shoot yourself in the foot, is to have such innocent rule:

genrule(
  name = 'foo',
  srcs = glob(['**']),
  [...]

Now you are screwed up, because Buck copying all files to foo__srcs, including BUCK file itself, and later, when you are trying to run buck test (note, that buck build * still works) it will complain that

//buck-out/.../foo: is not there or something

So now, all glob(['**']) must be extended with srcs = glob(['**'], excludes = ['BUCK']), as in : [1]. May be this should be added to the documentation? Now it's claiming that:

Buck automatically excludes its own output, e.g. <code>buck-out</code>,

https://gerrit-review.googlesource.com/#/c/72684/1/polygerrit-ui/app/BUCK@41

@Coneko
Copy link

Coneko commented Nov 25, 2015

Good point.

@shs96c something else to keep in mind for how the new FileHashCache should work.

@Coneko Coneko changed the title buck test interferes with output files written by Eclipse Buck parses build files in buck-out Nov 25, 2015
openstack-gerrit pushed a commit to openstack-infra/gerrit that referenced this issue Dec 3, 2015
The new Buck version fixed annoying stdout spamming bug on unit test
failures: [1]. Now we can revert our monkey patching hack to prevent
that.

Since [2] Buck interferes with files in buck-out directory: [3]. Switch
to using eclipse-out directory as Eclipse output directory instead. For
this change it's necessary to clean up buck-out directory, otherwise
`buck test` would fail.

This version also fixed "Python client lost connection" bug: [4].

This reverts commit 94e93aa.

[1] facebook/buck#505
[2] facebook/buck@35cb495
[3] facebook/buck#527
[4] facebook/buck#534

Change-Id: I4cd1a99ce9d0615713c235d873e6cdd61b1854bb
@LegNeato
Copy link
Contributor

LegNeato commented Jan 2, 2016

From what I can gather not really knowing the code, DirectoryTraversal can take ignore paths:

public DirectoryTraversal(Path root, ImmutableSet<Path> ignorePaths) {

It looks like some places it is called don't ever put ignore paths in:

https://github.com/facebook/buck/search?utf8=%E2%9C%93&q=DirectoryTraversal%28

Then again, the project filesystem appears to ignore it:

builder.add(Paths.get(BuckConstant.BUCK_OUTPUT_DIRECTORY));

And parsing build files appears to use it:

Might be a good place to poke around and send in a patch if you find the issue!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants