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

Force /bin/bash shell for conda #6386

Merged
merged 1 commit into from
Sep 27, 2024
Merged

Force /bin/bash shell for conda #6386

merged 1 commit into from
Sep 27, 2024

Conversation

Thireus
Copy link
Contributor

@Thireus Thireus commented Sep 17, 2024

I have found that conda may use a different shell in some instances, such as /bin/sh. This fix ensures it executes /bin/bash instead.

Checklist:

I have found that conda may use a different shell in some instances, such as /bin/sh. This fix ensures it executes /bin/bash instead.
@oobabooga oobabooga merged commit 626b0a0 into oobabooga:dev Sep 27, 2024
@Touch-Night
Copy link
Contributor

Touch-Night commented Sep 29, 2024

This PR breaks TextGenWebui on Windows.

Possible solution:

def run_cmd(cmd, assert_success=False, environment=False, capture_output=False, env=None):
    executable = None
    # Use the conda environment
    if environment:
        if is_windows():
            conda_bat_path = os.path.join(script_dir, "installer_files", "conda", "condabin", "conda.bat")
            cmd = f'"{conda_bat_path}" activate "{conda_env_path}" >nul && {cmd}'
        else:
            conda_sh_path = os.path.join(script_dir, "installer_files", "conda", "etc", "profile.d", "conda.sh")
            cmd = f'. "{conda_sh_path}" && conda activate "{conda_env_path}" && {cmd}'
            executable = '/bin/bash'

    # Run shell commands
    result = subprocess.run(cmd, shell=True, executable=executable, capture_output=capture_output, env=env)

    # Assert the command ran successfully
    if assert_success and result.returncode != 0:
        print(f"Command '{cmd}' failed with exit status code '{str(result.returncode)}'.\n\nExiting now.\nTry running the start/update script again.")
        sys.exit(1)

    return result

oobabooga added a commit that referenced this pull request Sep 29, 2024
@oobabooga
Copy link
Owner

Thanks @Touch-Night, this should be fixed after 055f3f5

@LuNeder
Copy link
Contributor

LuNeder commented Oct 2, 2024

This breaks systems that do not have bash at /bin/bash, such as NixOS, which was previously fixed at #6110

Setting executable='bash', as opposed to executable='/bin/bash', works, fixes this and should force bash well enough for the purposes of this pull request

@oobabooga
Copy link
Owner

@LuNeder can you make a PR?

@LuNeder
Copy link
Contributor

LuNeder commented Oct 3, 2024

@LuNeder can you make a PR?

Done

But is this force bash thing actually required at all? Shouldn’t conda use the shell it needs no matter what shell it’s ran from? Well, their conda/miniconda installer script is cursed af so it wouldn’t surprise me if they did cursed stuff in conda too, but if the shell you’re running the conda command from actually affects condas behaviour then we should probably open an issue or pull request >to conda itself< in the first place. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants