new_local_repository build_file BuildType$SelectorList cannot be cast to java.lang.String

46 views
Skip to first unread message

rober...@verbsurgical.com

unread,
May 23, 2016, 5:30:43 PM5/23/16
to bazel-discuss
I'm trying to use new_local_repository with build_file. I would like to use select() to choose build_file based on configuration (I want to target multiple platforms). Is this expected to work? I am using bazel 0.2.3 (from Linux installer) and getting the following failure:

$ bazel build foo:foo
..
Unhandled exception thrown during build; message: Unrecoverable error while evaluating node 'REPOSITORY_DIRECTORY:@bar' (requested by nodes 'REPOSITORY:@bar')
INFO: Elapsed time: 1.079s
java.lang.RuntimeException: Unrecoverable error while evaluating node 'REPOSITORY_DIRECTORY:@bar' (requested by nodes 'REPOSITORY:@bar')
        at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:1003)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:515)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: wrong type for attribute "build_file" in rule //external:bar
        at com.google.devtools.build.lib.packages.AbstractAttributeMapper.get(AbstractAttributeMapper.java:69)
        at com.google.devtools.build.lib.rules.repository.NewRepositoryBuildFileHandler.getBuildFileValue(NewRepositoryBuildFileHandler.java:120)
        at com.google.devtools.build.lib.rules.repository.NewRepositoryBuildFileHandler.prepareBuildFile(NewRepositoryBuildFileHandler.java:77)
        at com.google.devtools.build.lib.rules.repository.NewLocalRepositoryFunction.fetch(NewLocalRepositoryFunction.java:50)
        at com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction.compute(RepositoryDelegatorFunction.java:123)
        at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:954)
        ... 4 more
Caused by: java.lang.ClassCastException: com.google.devtools.build.lib.packages.BuildType$SelectorList cannot be cast to java.lang.String
        at com.google.devtools.build.lib.syntax.Type$StringType.cast(Type.java:377)
        at com.google.devtools.build.lib.syntax.Type$StringType.cast(Type.java:374)
        at com.google.devtools.build.lib.packages.AbstractAttributeMapper.get(AbstractAttributeMapper.java:65)
        ... 9 more

My test project is attached.

What am I doing wrong?

Thanks,
--Rob
test.tar.gz

Kristina Chodorow

unread,
May 24, 2016, 10:36:30 AM5/24/16
to rober...@verbsurgical.com, bazel-discuss
You can't use select() in the WORKSPACE file.  I filed https://github.com/bazelbuild/bazel/issues/1307 to make Bazel give an actual error message (instead of dumping a stack trace).

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/0947cb5a-c34d-472f-9236-6d49eb172f38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages