ERROR: no such package '@rules_pkg//': java.io.IOException: Error downloading [https://github.com/bazelbuild/rules_pkg/releases/download/0.2.5/rules_pkg-0.2.5.tar.gz, https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.2.5/rules_pkg-0.2.5.tar.gz] to /private/var/tmp/_bazel_ysong2/b326506f60d8e1a7b80e7181271420e8/external/rules_pkg/temp3975631198066234777/rules_pkg-0.2.5.tar.gz: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
any one could help on this?
 Hi, @ysong2123 

Apologize for the delay and it seems like the problem is due to SSL certificate on your machine and at the moment I'm providing some useful links which will help you to solve your SSL certificate problem [Ref-1](https://docs.mend.io/en-US/bundle/wsk/page/how_to_resolve_error_message__pkix_path_building_failed__sun_security_provider_certpath_suncertpathbuilderexception__unable_to_find_valid_certification_path_to_requested_target_.html), [Ref-2](https://stackoverflow.com/questions/21076179/pkix-path-building-failed-and-unable-to-find-valid-certification-path-to-requ#:~:text=28-,Mac,-The%20accepted%20answer), [Ref-3](https://stackoverflow.com/questions/6908948/java-sun-security-provider-certpath-suncertpathbuilderexception-unable-to-find#:~:text=And%20if%20you%20are%20here%20in%202022%20and%20are%20on%20mac%20follow%20this) so please try to follow workaround from those references and please let me know is it resolving your issue?

Just to confirm are you looking to install `Tensorflow 2.11` build from source or you just want to install Bazel on Macos ? I hope you're following this [official documentation](https://www.tensorflow.org/install/source#macos) to install Tensorflow build from source

I'll also try to install `Tensorflow 2.11` build from source on `MacOS` once you confirm that you're looking to install `Tensorflow 2.11 `build from source so please confirm it ? Thank you! Hi Gaikwadrahul8,
Yes, i strictly followed the steps in the official doc,  after git clone tensorflow,    then cd to root directory,         then try:
'bazel  build //tensorflow/tools/pip_package:build_pip_package' (all prerequisites have been installed in advance),   finally i got the certificate issue above.
BTW,  the Ref-1,2,3 you shared above are talking about java home,    may i know where's the java home for bazel build?   i already tried to export certificate and added into my local macOS java home keystore,   but i still got the same ssl exception. Hi, @ysong2123 

Thank you for the details and usually users get this error `PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target` due to the system firewall. The system firewall restricts the application to connect to external systems. The firewall requires a valid certificate to allow access to the external systems.

Could you please confirm, whether you're installing [Bazel](https://bazel.build/install) normally or via `Bazelisk` because [Bazelisk](https://github.com/bazelbuild/bazelisk) is an easy way to install Bazel and automatically downloads the correct Bazel version for TensorFlow and if you're using Bazelisk then please download manually and please follow below steps :

1. `wget https://github.com/bazelbuild/bazelisk/releases/download/v1.16.0/bazelisk-darwin-arm64` (If you get any error with respect to certificate then you can use this command `wget --no-check-certificate https://github.com/bazelbuild/bazelisk/releases/download/v1.16.0/bazelisk-darwin-arm64`

2. `chmod +x bazelisk-darwin-arm64`

3. `sudo mv bazelisk-darwin-arm64 /usr/local/bin/bazel`

If you have already done above steps and installed Bazel correctly then please execute below steps to see the Bazel or Bazelisk location and if possible please help me with those details 

```
1. whereis bazel
2. whereis bazelisk
```

I'll try to install Tensorflow on my MacOS from my end till then by following our official documentation and I'll update the same here. Thank you! ysong@LM-SHB-40523659 tensorflow % whereis bazel
bazel: /opt/homebrew/bin/bazel
ysong@LM-SHB-40523659 tensorflow % whereis bazelisk
bazelisk: /opt/homebrew/bin/bazelisk
ysong@LM-423659 tensorflow % 
ysong@LM-423659 tensorflow % bazel version
Bazelisk version: development
Another command (pid=24928) is running. Waiting for it to complete on the server (server_pid=24932)...
Build label: 5.3.0
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Aug 23 01:07:52 2022 (1661216872)
Build timestamp: 1661216872
Build timestamp as int: 1661216872

My new finding:
after run cmd in tensorflow root directory:      
'bazel  build //tensorflow/tools/pip_package:build_pip_package',  
Then i found  there's a jdk env auto-generated under path:
/private/var/tmp/_bazel_ysong2/install/3c4a7a3c33b4c067b191587b066e5f1b/embedded_tools/jdk/

this JDK is isolated with my local JDK env.    so i wrote a simple java demo tried to make a java ssl call to get tensorflow dependencies.    If i use my local JDK(openjdk8 or openjdk11) i can get those dependencies with no any exception.  
But when i pointed to /private/var/tmp/_bazel_ysong2/install/3c4a7a3c33b4c067b191587b066e5f1b/embedded_tools/jdk/, 
i got the same ssl issue.          

Besides, i tried to copy my local jdk to /private/var/tmp/_bazel_ysong2/install/3c4a7a3c33b4c067b191587b066e5f1b/embedded_tools/jdk/,   then i got Fatal error：
FATAL: corrupt installation: file '/var/tmp/_bazel_ysong2/install/3c4a7a3c33b4c067b191587b066e5f1b/embedded_tools/jdk/ASSEMBLY_EXCEPTION' is missing or modified.  Please remove '/var/tmp/_bazel_ysong2/install/3c4a7a3c33b4c067b191587b066e5f1b' and try again.

Is there any way to adopt my local jdk for bazel build? i solved this problem using :
https://bazel.build/install/compile-source#bootstrap-unix.  
I commented out 'for' statement and rebuild a binary version of bazel:
https://github.com/bazelbuild/bazel/blob/master/src/main/cpp/blaze.cc#L1015
Then using this to build tensorflow, no any exception now
 Hi, @ysong2123 

Good to hear that you're able to resolve your issue and even I was able to install `Tensorflow` build from source with `Bazelisk` approach and it seems like in your case there was some conflict between local JDK and Bazel embedded JDK and it got resolve by this command `env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" bash ./compile.sh`

I have added screenshot below for your reference with `Bazelisk` Approach:

![image](https://user-images.githubusercontent.com/115997457/219292576-852d0a0f-ab4d-4e45-9d2b-c6be84e3f187.png)

Could you please confirm if this issue is resolved for you ? Please feel free to close the issue if it is resolved ? if you need any further assistance please let us know? Thank you!

 Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/59669">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/59669">No</a>

<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Build/Install

### Have you reproduced the bug with TF nightly?

No

### Source

source

### Tensorflow Version

tag: v2.11.0

### Custom Code

No

### OS Platform and Distribution

MacOS Montery 12.6.1

### Mobile device

_No response_

### Python version

3.9

### Bazel version

5.6

### GCC/Compiler version

clang 14.0

### CUDA/cuDNN version

none

### GPU model and memory

none

### Current Behaviour?

```shell
ERROR: no such package '@rules_pkg//': java.io.IOException: Error downloading [https://github.com/bazelbuild/rules_pkg/releases/download/0.2.5/rules_pkg-0.2.5.tar.gz, https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.2.5/rules_pkg-0.2.5.tar.gz] to /private/var/tmp/_bazel_ysong2/b326506f60d8e1a7b80e7181271420e8/external/rules_pkg/temp3975631198066234777/rules_pkg-0.2.5.tar.gz: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

tried add certificates into keystore but doesn't work.
```


### Standalone code to reproduce the issue

```shell
ERROR: no such package '@rules_pkg//': java.io.IOException: Error downloading [https://github.com/bazelbuild/rules_pkg/releases/download/0.2.5/rules_pkg-0.2.5.tar.gz, https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.2.5/rules_pkg-0.2.5.tar.gz] to /private/var/tmp/_bazel_ysong2/b326506f60d8e1a7b80e7181271420e8/external/rules_pkg/temp3975631198066234777/rules_pkg-0.2.5.tar.gz: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
```


### Relevant log output

_No response_</details>