Reflex installs Bun even though BUN_PATH is set
Describe the bug
Reflex installs Bun even though BUN_PATH is set.
To Reproduce
- Install Bun manually. However, the version of Bun is different from
constants.Bun.VERSION. - Set an environment variable
BUN_PATHas the installed bun path. - Run
reflex init.
Expected behavior The installation of Bun would be skipped.
Additional context The condition of Bun installation seems incorrect.
Current implementation: https://github.com/reflex-dev/reflex/blob/b01c4b6c6a0d5642079b73be6a5c27193730e425/reflex/utils/prerequisites.py#L795-L800
I suppose this should be changed as below:
# Skip if bun is already installed.
bun_path = get_config().bun_path
if bun_path != constants.Bun.DEFAULT_PATH or os.path.exists(bun_path) and get_bun_version() == version.parse(
constants.Bun.VERSION
):
console.debug("Skipping bun installation as it is already installed.")
return
PR #4006 is introducing REFLEX_USE_SYSTEM_BUN as an env var.
Let us know if this solve the issue for you.
@Lendemor Thank you for your response.
There seems to be a new bug in prerequisites.get_bun_version.
The version of Bun is resolved at following code, but REFLEX_USE_SYSTEM_BUN is not considered.
https://github.com/reflex-dev/reflex/blob/3eab2b6e7d8dab972b9e5714a845777d664e7ecb/reflex/utils/prerequisites.py#L1044
https://github.com/reflex-dev/reflex/blob/3eab2b6e7d8dab972b9e5714a845777d664e7ecb/reflex/utils/prerequisites.py#L196
Compared to prerequisites.get_node_version, it seems that path_ops.get_bun_path() should be used instead of get_config().bun_path.
https://github.com/reflex-dev/reflex/blob/3eab2b6e7d8dab972b9e5714a845777d664e7ecb/reflex/utils/prerequisites.py#L159
Sorry for the delay in getting back to you on this.
Made a PR that should fix the issue with bun_path, let me know if you can give it a try.