-
Notifications
You must be signed in to change notification settings - Fork 304
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
WSL2 terminal doesn't source .profile #6096
Comments
Apologies if I'm misunderstanding, but did you install the Python module in step 1 on the WSL side or the Windows side? If installed on the WSL side, does |
I can confirm that .profile is not being sourced by the wsl remote terminal. Had my GPG_TTY export in there, along with some docker-related stuff. had to move it all out into .bashrc. @vectorcrumb |
@jmullman I tried adding the following to
where
Is this impossible then and should I prefer using @bamurtaugh The error appears only using the integrated VS Code terminal and not using a windows WSL2 terminal. |
@tanhakabir @aeschli I noticed a similar report in #5852, where a user mentioned Remote-WSL was also affected by this. Do you think this would be related to the fix from that issue (microsoft/vscode#136791)? |
@vectorcrumb Your log says: |
Same problem here. I've installed WSL2, Python and Pip. On my .profile i have: # set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi If i try something like If i enter Why WSL2 does not source automatically when i open a new WSL2 terminal? My .profile file: # if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi |
@Tyriar FYI |
I believe the VS Code server does not run a login shell when it starts up the server, this is a difference with desktop VS Code which does. On Linux we run a non-login shell by default in the terminal, so it picks up the changes from the profile only on desktop, not the server. I think I suggested changing how the server launched at some point but understandably that was a very risky change to do. Not sure what we should do here but defining your terminal profile to be a login shell should workaround the problem: "terminal.integrated.defaultProfile.linux": "bash (login)",
"terminal.integrated.profiles.linux": {
"bash (login)": {
"path": "bash",
"args": [
"-l"
],
"icon": "terminal-bash"
},
} |
This is exactly how |
You are absolutely right. When wsl is started, the first terminal I opened does not source .profile, but the next does. I used |
I have basically the same issue: the first terminal opened when I open WSL ignores my terminal profile. Here is the settings.json of my profile : |
Using the deprecated way solved my problem temporarly: |
This is a elusive long standing issue where whenever we fix it, there's some edge case we hadn't covered. Tracked in microsoft/vscode#175107 |
I'm on a clean Windows 11 install, with a brand-new default WSL installation - literally just Brand new installation of VS Code as well. And it doesn't work. So not really an edge case, I think? Likely everyone with a brand-new Win 11, WSL 2, VS Code install will hit this well. @Tyriar I copied your settings from here and it does appear to run my
I see that sudo message every time I open a console - my Maybe running something twice is/was a temporary workaround for things not working the first time? |
That file ( Strangely enough, it is when you open Tmux. |
I've just figured out why: only shopt login_shell Hence, I suggest doing as this answer says [2]:
[1] https://askubuntu.com/a/121083 |
On my latest WSL2 install, my |
I have this issue also on a fresh install of W11, WSL, and VSCode. I found my To my
And commented out code in |
That's a much better workaround, indeed. |
Any clue what changed? |
Fixed by adding the code from #6096 (comment) added to my But yeah, something definitely changed. Was the integrated terminal using a login shell before and this changed sometime last year? |
I don't have any plans to change how terminal profiles work when in a remote as that would lead to other weird inconsistencies. @aeschli the remote owner(s) need to either address this by sourcing the profile in the shell that launches the server, or accept it as designed (maybe document somewhere if it's not already?). When I've discussed this in the past with @roblourens it was deemed too risky of a change to do after so long. cc @joshspicer as you might be tracking a similar problem in SSH. |
@CS-Account I always just assumed they fixed it already? I don't recall doing anything about it myself - I'm a very basic Linux user, I don't think I'd know how to.
@louiswdavis on my system,
@louiswdavis I checked my
@Tyriar I don't think you need to change anything? My current WSL2 Linux is the standard/default one. (Ubuntu 22.04.4 LTS, jammy) As I wrote here on October 8 '23, it just started working on my latest WSL2 Linux install - I checked the So I'd expect this was an issue with earlier releases of the default WSL2 Linux distro? Most likely, folks in this thread, who are still having problems, are using an earlier version of the default Linux distro? or perhaps they're using a different Linux distro from the default/standard one? If someone here would care to create a new (or second) Linux install with the default/standard OS, perhaps we could confirm this? |
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 10 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation. Happy Coding! |
Yes, it's a risky change. Why initially had it like that but then ran into many issues with mis-configured startup scripts preventing us from starting the server or detecting the environment. |
Issue Type: Bug
When loading a WSL2 window and opening a terminal, the
.profile
located in the user directory isn't loaded. The steps I took were:python3 -m pip install -U fprime-tools
. An executable is installed in$HOME/.local/bin
. This can be verified by runningfprime-util
in a terminal window.fprime-util
results in acommand not found
error. Upon verifying the path withecho $PATH
, the folder$HOME/.local/bin
isn't found. However, this folder should be added to the path by.profile
.Also, variables defined by
.bashrc
can be found inside the shell, therefore the issue should arise from VS Code not sourcing the.profile
file.Extension version: 0.63.13
VS Code version: Code 1.63.2 (899d46d82c4c95423fb7e10e68eba52050e30ba3, 2021-12-15T09:40:02.816Z)
OS version: Windows_NT x64 10.0.22000
Restricted Mode: No
Remote OS version: Linux x64 5.10.60.1-microsoft-standard-WSL2
The text was updated successfully, but these errors were encountered: