Skip to content
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

Can't use external repo as vendored_node #464

Closed
mboes opened this issue Dec 9, 2018 · 7 comments
Closed

Can't use external repo as vendored_node #464

mboes opened this issue Dec 9, 2018 · 7 comments
Labels
bug Can Close? We will close this in 30 days if there is no further activity
Milestone

Comments

@mboes
Copy link
Contributor

mboes commented Dec 9, 2018

🐞 bug report

Affected Rule

The issue is caused by the rule: node_repositories().

Is this a regression?

No

Description

I'd like to use NodeJS from Nixpkgs. Using rules_nixpkgs, I can map the Nixpkgs package for NodeJS to a Bazel external repository. This repository has the following content:

bin/node
bin/npm
...

To use this, I say:

nixpkgs_package(
    name = "nixpkgs_nodejs",
    attribute_path = "nodejs",
    repository = "@nixpkgs",
)

nixpkgs_package(
    name = "nixpkgs_yarn",
    attribute_path = "yarn",
    repository = "@nixpkgs",
)

node_repositories(vendored_node = "@nixpkgs_nodejs", vendored_yarn ="@nixpkgs_yarn")

in my WORKSPACE file. But this doesn't work.

🔬 Minimal Reproduction

Checkout https://github.com/mboes/rules_nodejs/commit/72caa8a90653f5a1d66895bcd20a0de9210f2b29. Then

$ bazel build //...

🔥 Exception or Error




/home/mboes/.cache/bazel/_bazel_mboes/6ebb4a176e70acabad01519e5e923b54/external/nodejs/bin/node: ligne 17: /home/mboes/.cache/bazel/_bazel_mboes/6ebb4a176e70acabad01519e5e923b54/external/nodejs/bin/../../../external/somedir/somedir/bin/node: No such file or directory

Notice how the above is looking for external/somedir/somedir/bin/node when the binary (just an empty file in the repro) is actually at external/somedir/bin/node. I could modify rules_nixpkgs to add a symlink called external/somedir/somedir that points to external/somedir for any somedir external repo it creates, but then I run into bazelbuild/bazel#2927.

🌍 Your Environment

Operating System:

  
Linux
  

Output of bazel version:

  
Build label: 0.20.0- (@non-git)
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jan 1 00:00:00 1980 (315532800)
Build timestamp: 315532800
Build timestamp as int: 315532800
  

Rules version (SHA):

  
d554d80c5718c130af6a21a07057c35bb1b3b4ea
  
@mgechev mgechev added the bug label Dec 10, 2018
@alexeagle alexeagle added this to the Backlog milestone Dec 18, 2018
@dgarzon
Copy link

dgarzon commented Feb 12, 2019

Hi @mboes did you find a way to get this working? I would also like to use the nix provided binaries, but am running into your same issue. Thanks in advanced!

@mboes
Copy link
Contributor Author

mboes commented Feb 12, 2019

Here's the code we use currently rules_haskell: https://github.com/tweag/rules_haskell/blob/master/WORKSPACE#L246-L297. That code works around this bug in a way that also works around bazelbuild/bazel#2927, using a Nix derivation that wraps the actual Nix derivation for NodeJS.

@dgarzon
Copy link

dgarzon commented Feb 13, 2019

Thank you very much @mboes ! That did the tick for me 👍

@robinp
Copy link

robinp commented Oct 3, 2019

Oops! Almost reopened the same issue. Pasting the report, for posterity (which is along the lines of @mboes 's)
When using the vendored_node option of node_repositories, I can't seem to specify a repository which has top-level bin/node layout.

For example, the repository I vendor from is @my_node, inside which the node binary resides at //:bin/node. If I pass vendored_node = "@my_node", the path that rules_nodejs looks for bin/node is ..../my_node/my_node/bin/node (note the duplicate my_node path).

I needed to transform the repository and introduce an additional top directory and an accompanying filegroup, so I can pass vendored_node = "@my_node//:top", which works but is a hack.

Related path construction rules are around https://github.com/bazelbuild/rules_nodejs/blob/7e3e6be38e1cf3c6c99d8dc8829377a2beacbb53/internal/node/node_repositories.bzl#L329.

I could solve it, but would be convenient if changing the repo layout would not be needed. Thank you!

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had any activity for 90 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

@github-actions github-actions bot added the Can Close? We will close this in 30 days if there is no further activity label Nov 18, 2020
@github-actions
Copy link

github-actions bot commented Dec 2, 2020

This issue was automatically closed because it went two weeks without a reply since it was labeled "Can Close?"

@github-actions github-actions bot closed this as completed Dec 2, 2020
@alexeagle
Copy link
Collaborator

dupe of #2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Can Close? We will close this in 30 days if there is no further activity
Projects
None yet
Development

No branches or pull requests

5 participants