reflex icon indicating copy to clipboard operation
reflex copied to clipboard

Reflex installs Bun even though BUN_PATH is set

Open n0r1z0 opened this issue 1 year ago β€’ 1 comments

Describe the bug Reflex installs Bun even though BUN_PATH is set.

To Reproduce

  1. Install Bun manually. However, the version of Bun is different from constants.Bun.VERSION.
  2. Set an environment variable BUN_PATH as the installed bun path.
  3. 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

n0r1z0 avatar Aug 14 '24 04:08 n0r1z0

PR #4006 is introducing REFLEX_USE_SYSTEM_BUN as an env var. Let us know if this solve the issue for you.

Lendemor avatar Sep 26 '24 22:09 Lendemor

@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

n0r1z0 avatar Oct 23 '24 03:10 n0r1z0

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.

Lendemor avatar Jan 24 '25 16:01 Lendemor