aspect-build / aspect-cli

correct, fast, usable: choose three
https://aspect.build/cli
Apache License 2.0
93 stars 21 forks source link

[Bug]: Set `BAZELISK_HOME` to `~/.bazeliskrc` or existance of that dir makes CLI errors and exit #719

Open albertocavalcante opened 4 months ago

albertocavalcante commented 4 months ago

What happened?

I still may need to re-reproduce and confirm my findings but I'm already sharing it anyway. I'll update this issue accordingly.

The error I'm currently getting:

Standalone Aspect CLI

$ aspect
2024/07/03 01:54:22 read /home/alberto/.bazeliskrc: is a directory

Bazelisk

$ bazelisk help init
2024/07/03 01:58:14 read /home/alberto/.bazeliskrc: is a directory

Version

Development (host) and target OS/architectures: linux_x86_amd4 (WSL2)

Output of bazel --version: Errors out

Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file: None

Language(s) and/or frameworks involved: None

How to reproduce

touch WORKSPACE

echo 7.2.1 > .bazelversion

cat > .bazeliskrc << EOF
BAZELISK_HOME=~/.bazeliskrc # EDIT: was supposed to be .bazelisk
BAZELISK_BASE_URL=https://github.com/aspect-build/aspect-cli/releases/download
USE_BAZEL_VERSION=aspect/5.10.1
EOF

Then:
`bazelisk init`
`bazelisk help init`

and from now on:

`aspect` also fails.

Any other information?

(Note: I'm using a fork of bazelisk which carries these changes only: https://github.com/bazelbuild/bazelisk/pull/587, to reproduce it you can change ~ with the actual homedir path).

albertocavalcante commented 4 months ago

Actually I've just realized my mistake, I've inadvertently set BAZELISK_HOME to ~/.bazeliskrc, that's why it failed.

This is clearly not a bug but bad user behavior. Still I'm planning to open a PR to improve the error message. (In fact I think it can detect a situation when the BAZELISK_HOME matches the rcFileName and prevent it from executing, marking a "forbidden" path). Although it's very unlikely someone will make the same mistake I just did.

I noticed you have your own fork of bazelisk.go, will leave it open if you think it worth it, otherwise feel free to close it. Thanks.

(will also edit the title)