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

Terminal profile settings not reflected in terminals created using VSCode API #192943

Open
karrtikr opened this issue Sep 12, 2023 · 12 comments
Open
Assignees
Labels
feature-request Request for new features or functionality terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. terminal-profiles
Milestone

Comments

@karrtikr
Copy link
Contributor

Does this issue occur when all extensions are disabled?: Yes/No

Version: 1.83.0-insider
Commit: 03671d332bf6a34782d5adc64086bc8e083a1590
Date: 2023-09-12T15:02:37.804Z
Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Steps to Reproduce:

  1. Configure fish profile to also set an environment variable:
        "fish": {
            "path": "fish",
            "env": {
                "fish_history": "history"
            }
        },
  1. Select this as default terminal profile

  2. Create a terminal and print variables, notice fish_history is present:
    image

  3. Create a terminal using vscode.window.createTerminal() API, notice many variables including this are not present:
    image

For Python extension, this leads to "Python" terminals being different from the selected terminal: microsoft/vscode-python#21960. Created on behalf of @kyochikuto.

@karrtikr karrtikr changed the title Terminal env settings not reflected in terminals created using VSCode API Terminal profile settings not reflected in terminals created using VSCode API Sep 12, 2023
@meganrogge meganrogge added bug Issue identified by VS Code Team member as probable bug terminal-profiles terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. labels Sep 13, 2023
@Tyriar
Copy link
Member

Tyriar commented Sep 13, 2023

I think this is by design because you're launching a shell, not a profile. Unless you don't specify a shellPath in which case I haven't really thought about what's meant to happen.

@Tyriar Tyriar added under-discussion Issue is under discussion for relevance, priority, approach and removed bug Issue identified by VS Code Team member as probable bug labels Sep 13, 2023
@ghost
Copy link

ghost commented Sep 13, 2023

I believe we're always launching a shell, but with terminal.integrated.profiles.linux we just customize as to how we're doing it. Right now I can manually hit New Terminal and then do python script.py to have the profile settings set during execution but it's somehow cumbersome.

And if it is by design, I'm curious as to why and what are the benefits (since it seems counter-intuitive to me IMHO)?

@Tyriar
Copy link
Member

Tyriar commented Sep 13, 2023

@kyochikuto it's by design from what the extension API does since it's setting a shellPath property not profile, it's not necessarily what the Python extension was going for.

@ghost
Copy link

ghost commented Sep 13, 2023

@karrtikr What is your take? From what I understand of @Tyriar comments, Python-ext is more appropriate to implement this, correct?

@karrtikr
Copy link
Contributor Author

karrtikr commented Sep 13, 2023

I think this is by design because you're launching a shell, not a profile

I would expect the behavior of vscode.window.createTerminal() to be same as when clicking:

image
to open a new terminal. I think it was this way before the concept of terminal profiles got introduced.

@Tyriar How do we launch such a terminal using vscode API?

@Tyriar
Copy link
Member

Tyriar commented Sep 14, 2023

@karrtikr do you explicitly set the shellPath currently?

@karrtikr
Copy link
Contributor Author

Nope, just the name.

@Tyriar
Copy link
Member

Tyriar commented Sep 14, 2023

I think it was this way before the concept of terminal profiles got introduced.

This is right, profiles launching from the extension host was just never considered.

Thinking about it now the way I would expect it to work is for all props of the default profile to be picked up if shellPath and shellArgs are undefined. I'm a little concerned if we just turn on linking profiles details as it might break some extensions, but I guess that's the right behavior.

@karrtikr do you have bandwidth to look into implementing this? It's probably just a matter of calling into ITerminalProfileResolverService when extension terminals get initialized.

@ghost
Copy link

ghost commented Sep 14, 2023

I actually need this to prevent VS Code from cluttering my shell history, otherwise my history is filled up with entries such as source /some/path/.venv/bin/activate.fish and /some/path/.venv/bin/python /some/path/src/myscript.py or subsequent commands I tried for that specific project which are irrelevant as my shell history in my general day to day usage!

Setting terminal.integrated.shellIntegration.history to 0 did not have any effect, at least on my fish shell, not sure if it's a bug or I'm missing something! Nor did having fish_history= in a .env file and opting into the newly introduced "python.experiments.optInto": [ "pythonTerminalEnvVarActivation" ].

@Tyriar
Copy link
Member

Tyriar commented Sep 15, 2023

@kyochikuto thanks for the info, I created microsoft/vscode-python#21998 to hopefully solve the issue you're having regardless of this ask. You can also check if TERM_PROGRAM = vscode ad handle it specially vscode's terminal specially in your shell init which may be helpful.

@karrtikr
Copy link
Contributor Author

karrtikr commented Sep 15, 2023

Nor did having fish_history= in a .env file and opting into the newly introduced "python.experiments.optInto": [ "pythonTerminalEnvVarActivation" ]

@kyochikuto This should be fixed with microsoft/vscode-python#22004, I've opened microsoft/vscode-python#22005 on your behalf to verify this.

@ghost
Copy link

ghost commented Dec 2, 2023

This is indeed fixed and I can properly set env vars for my fish shell now, thank you for your time and attention!

@Tyriar Tyriar added this to the Backlog milestone Dec 8, 2023
@Tyriar Tyriar added feature-request Request for new features or functionality and removed under-discussion Issue is under discussion for relevance, priority, approach labels Dec 8, 2023
@Tyriar Tyriar removed their assignment Dec 9, 2024
@meganrogge meganrogge assigned Tyriar and unassigned meganrogge Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. terminal-profiles
Projects
None yet
Development

No branches or pull requests

3 participants