warpdotdev / Warp

Warp is a modern, Rust-based terminal with AI built in so you and your team can build great software, faster.
https://warp.dev
Other
21.35k stars 373 forks source link

Conda environment name display is abnormal #3942

Open kongds1999 opened 11 months ago

kongds1999 commented 11 months ago

Discord username (optional)

No response

Describe the bug

Only the basic environment name base can be displayed, and the switching environment cannot be displayed normally. image

To reproduce

  1. open the warp
  2. conda activate SPA (if base environment is prepared)
  3. The terminal still only shows base, not SPA.

Expected behavior

No response

Screenshots

No response

Operating system

MacOS

Operating system and version

14.2.0

Shell Version

No response

Current Warp version

v0.2023.11.28.08.02.stable_00

Regression

No, this bug or issue has existed throughout my experience using Warp

Recent working Warp date

No response

Additional context

No response

Does this block you from using Warp daily?

No

Is this a Warp specific issue? (i.e. does it happen in Terminal, iTerm, Kitty, etc.)

No, this same issue happens in Warp and other terminals.

Warp Internal (ignore): linear-label:b8107fdf-ba31-488d-b103-d271c89cac3e

None

dannyneira commented 11 months ago

Hey @Kentonson, thanks for taking the time to submit this. Please make sure you have run conda init zsh (or whatever your default shell is). Then open a new session and run the conda info --envs to list the currently available environments to make sure SPA is available, if so, then run conda activate SPA to activate that environment. To exit the env you can run conda deactivate and it should exit the current env. See my example below activating different environments.

https://github.com/warpdotdev/Warp/assets/16809145/a409d1ea-624e-4c01-a0ed-fbe3d03f998b

Hope this helps with your issue, please let me know if the problem persists. To anyone else facing this issue, please add a :+1: to the original post at the top or comment with your details, and subscribe if you'd like to be notified.

dannyneira commented 11 months ago

@Kentonson It looks like you may be using a custom prompt (I can tell from the Icon in your prompt), I found this to be the same issue when using the starship.rs prompt. I was able to work around, this issue by running the following command: conda config --set auto_activate_base false

In my example, I set up the conda then activated some envs and noticed the same before: CleanShot 2023-12-11 at 11 20 04

After running conda config --set auto_activate_base false: CleanShot 2023-12-11 at 11 21 17

Also, make sure the Conda env is configured in your custom prompt, you may have to configure it in your config file (example of this in startship.rs docs https://starship.rs/config/#conda)

Please let me know if the above was helpful in resolving your issue.

kongds1999 commented 9 months ago

Thanks for your reply, I just had time to look into this today, and found that the problem was that I was using an oh-my-zsh theme config file, but the theme config file I was using did not include conda information by default, so I modified the theme file and now it works fine. If anyone else had issues with the . oh-my-zsh theme causing these issues, I found this answer can help you Firstly, find your theme file: use this command cd ~ and l

截屏2024-01-13 14 52 56

cd .oh-my-zsh/themes/

and then modify your theme configuration file with vim, Add the information: local conda_prompt='$(conda_prompt_info)' conda_prompt_info() { if [ -n "$CONDA_DEFAULT_ENV" ]; then echo -n "%{$terminfo[bold]$fg[green]%}($CONDA_DEFAULT_ENV) %{$reset_color%}" else echo -n '' fi }

image

Finally, modify the prompt line, add the ${conda_prompt}:

image

Modify according to your specific situation as the theme file I am using is alanpeabody.zsh-theme

chonkie3 commented 5 months ago

@kentonson, Ive run into the same issue, but I have no themes installed. I'm pretty much a beginner with warp or any other custom terminal other than terminal for that matter; any help here would be greatly appreciated. I still can't see the change in the env when I change from (base) to anything else. It displays (base) even though I've changed the env.

I love warp but need to use conda and really would like to find a way to get this to work.

kongds1999 commented 5 months ago

@chonkie3 Perhaps you can provide more detailed information like bug reports or images, so I can help you analyze this issue.

chonkie3 commented 5 months ago

Describe the bug Only the basic environment name base can be displayed, and the switching environment cannot be displayed normally.

To Reproduce Expected behavior You will notice the expected behavior on the regular OSX terminal on the image below

Priority Unable to notice the change in env for conda work

Screenshots/Video

Screenshot 2024-05-14 at 08 17 43

Screenshot 2024-05-14 at 08 31 16

Desktop OS: MacOS Sonoma 14.4.1 Device: Mac Mini 2023 M2

Warp Version v0.2024.05.07.08.02.stable_02

Conda Version 24.3.0

Additional context On the image, sorry for the lack of clarity. You will notice on warp I'm trying to change my base env from (base) to (/Users/.../Desktop/Code/env) and it doesn't change the name of the env. However on the mac terminal you can see the change from (base) to (/Users/.../Desktop/Code/env) happening as expected.

Let me know if you need any other information. I installed conda first then warp. No themes nor altering of code

kongds1999 commented 5 months ago

@chonkie3 Hi,there Ive run into the same issue recently. There was an error while activating the environment with the conda activate xx command, it gave me an error, which was the following output: CondaError: Run 'conda init' before 'conda activate' So I tried to use the conda init command to initialize and configure the shell (you can try to use this command in the conda deactivate state(no base) at the beginning). Under normal circumstances, this command will output some information about the configuration installation path of conda.

image

Then you can try using conda activate to activate your conda environment,If it succeeds, congratulations; if it still fails, you can use the source activate command to activate your base environment,

image

and then use conda activate xx again.

image

After this, all the problems I encountered have been solved. If there are any problems, you can continue to contact me. By the way, Mac currently uses the default $SHELL to be /bin/zsh. If you haven't made any changes, it should be the same. You can use the following command output to check: echo $SHELL Then use the following command to view your zsh prompt(or PS1): echo $PS1 This command is used to view your terminal prompt information. Please refer to this:

image

Of course, I configured this in the oh-my-zsh theme file. If you don't have this theme installed, you may need to modify it in the ~.zshrc file. You can search for how to modify zsh prompt or PS1 to display conda env. I hope this helps you.

chonkie3 commented 5 months ago

@kentonson thanks so much for your quick response. Weirdly enough I don't get an error when I try and activate a env. Here is my input and output based on your suggests:

Screenshot 2024-05-14 at 10 24 57

Anyone else able to help here? @dannyneira

kongds1999 commented 5 months ago

@chonkie3 Hi, again. I noticed a few problems with the information you gave me. First, you did not deactivate the base env after using the conda deactivate command. I was curious to see what the output of your echo $PS1 would be, as this is related to the prompt before your terminal command. In addition, when using source activate, you don't need to enter your conda environment name next, just source activate, like this:

image

and this command will normally start the default base environment

chonkie3 commented 5 months ago

@kentonson The reason why conda doesn't show that it's deactivated is because it literally can't be deactivated. when I type conda deactivate, it stays on the base env:

Screenshot 2024-05-14 at 12 28 48

kongds1999 commented 5 months ago

@chonkie3 I think I guessed correctly. Please note that the output of the echo $PS1 command is a fixed display of information, it is not a real conda base environment, Let's analyze the current meaning of prompt: %n: Displays login user name. %m: Displays the current host name, displays the local host name when logging in to the local terminal, and displays the server name when logging in to the remote server. %~: Displays the current working directory starting with ~, where ~ is the user's home directory $HOME, and the number specifies the number of layers to display the path. %#: Display #when the user has administrator privileges (root), otherwise display %.

So there is a lack of control to display conda env conditions, The easiest way is to use the following command to automatically configure the ~/.zshrc file: conda init or maybe: conda init zsh At this time, if you check ~/.zshrc, you may see something like the following results :

image

and then you can run this command to ensure that the configuration takes effect: source ~/.zshrc By the way, what is your source activate output?

chonkie3 commented 5 months ago

@kentonson I finally got it to work. This was how:

Screenshot 2024-05-14 191046

I literally tried everything else. I installed Conda possibly 6 times, back and forth trying everything ChatGPT had to throw at it. This was the winning formula

Gabriel-p commented 3 months ago

Related #5136 ?