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

user environment variables are not loaded #32

Closed
urubatan opened this issue May 3, 2019 · 15 comments
Closed

user environment variables are not loaded #32

urubatan opened this issue May 3, 2019 · 15 comments
Assignees
Labels
wsl Issue in vscode-remote WSL

Comments

@urubatan
Copy link

urubatan commented May 3, 2019

Issue Type: Bug

User environment variables are not loaded, making most processes not work (RVM doesn't work for example)
DOCKER_HOST is not set
DATABASE_HOST is also not set

Extension version: 0.32.0
VS Code version: Code - Insiders 1.34.0-insider (473af338e1bd9ad4d9853933da1cd9d5d9e07dc9, 2019-05-01T00:22:05.899Z)
OS version: Windows_NT x64 10.0.17763
Remote OS version: Linux x64 4.4.0-17763-Microsoft

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7Y75 CPU @ 1.30GHz (4 x 1608)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.89GB (5.29GB free)
Process Argv
Screen Reader no
VM 0%
Item Value
Remote WSL
OS Linux x64 4.4.0-17763-Microsoft
CPUs Intel(R) Core(TM) i7-7Y75 CPU @ 1.30GHz (4 x 1601)
Memory (System) 15.89GB (5.29GB free)
VM 0%
@kieferrm
Copy link
Member

kieferrm commented May 3, 2019

@urubatan, you're talking about WSL?

@kieferrm kieferrm added the info-needed Issue requires more information from poster label May 3, 2019
@urubatan
Copy link
Author

urubatan commented May 3, 2019

@kieferrm sorry, yes, I'm using the remote WSL

to workaround I changed the server.sh script to use bash instead of sh and forced loading the my user profile, works for most of the plugins but not all (for example, terminal, docker, all build tasks, work perfectly, docker-compose plugin doesn't appear to have the variable set)

but this is after "my small hack"

before that, no user env was available to the editor.

@Codelica
Copy link

Codelica commented May 3, 2019

May be related, if your shell is set to bash, remote-ssh appears to source .bashrc and but not .profile (like a full login shell typically does). Not sure if this is intentional or not. Sub-shells typically don't get .profile, but personally I wish it were included for this.

@Tyriar
Copy link
Member

Tyriar commented May 3, 2019

WSL does indeed appear to not run the server in a login shell (unlike the SSH extension).

@Tyriar Tyriar added wsl Issue in vscode-remote WSL and removed info-needed Issue requires more information from poster labels May 3, 2019
@Codelica
Copy link

Codelica commented May 3, 2019

Well, I'm not sure the SSH extension uses a login shell either (for the remote terminal at least). I'm definitely seeing .bashrc and not .profile sourced with that extension. But I started a separate issue for that @ #84.

@Tyriar
Copy link
Member

Tyriar commented May 3, 2019

@Codelica when you connect to the window on SSH the server is run in a login shell, when you open a terminal it inherits that environment and your shell launches a non-login shell.

@Codelica
Copy link

Codelica commented May 3, 2019

@Tyriar thanks for the info. :) looks like I can key off VSCODE_IPC_HOOK_CLI and add what I need in bashrc. 👍

@sskeirik
Copy link

sskeirik commented May 5, 2019

@Codelica @Tyriar Based on your combined input, I got my setup personally to work. Thanks! I did two things:

  1. Added a conditional in .bashrc based on value of VSCODE_IPC_HOOK_CLI
  2. Added VSCODE_IPC_HOOK_CLI/u to my WSLENV environment variable on the Windows side

The second step lets us resume editing a WSL workspace that we started earlier by just running code-insiders as usual on the Windows side, so that the value of the VSCODE_IPC_HOOK_CLI variable is properly shared from Windows to WSL and the right bash initialization logic kicks in.

@aeschli
Copy link
Contributor

aeschli commented May 6, 2019

The WSL server is started with bash -i ./script/wslServer.sh.
According to this, bash looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

When the terminal starts it does the same (@Tyriar Maybe that't not really necessary).

What doesn't work is when when you start code-insiders . from a WSL shell: We start a new shell for the server but do not copy the environment as it is present in the shell.
@urubatan Is that what you were expecting?

@urubatan
Copy link
Author

urubatan commented May 6, 2019 via email

@aeschli
Copy link
Contributor

aeschli commented May 6, 2019

@aeschli
Copy link
Contributor

aeschli commented May 7, 2019

@urubatan If you put a ECHO .bash_profile on the first line of ~/.bash_profile you will see that it is invoked. Check the content of the script to see what it further does and why DOCKER_HOST is not initialised.

@aeschli
Copy link
Contributor

aeschli commented May 7, 2019

@urubatan Sorry, you are right, I got confused. Currently, WSL is an interactive non-login shell. What's called is ~/.bashrc.

@urubatan
Copy link
Author

urubatan commented May 7, 2019 via email

@urubatan
Copy link
Author

@aeschli just to let you know that moving my environment initialization to ~/.bashrc worked both for env vars and for RVM to load project specific ruby versions (at least with default rvm ruby version, there is some directory change hook not being called but that is outside the scope of this bug and too specific for rvm :D )

Thanks a lot for helping clarify this env load issue 🥇

@aeschli aeschli reopened this May 11, 2019
@aeschli aeschli closed this as completed May 14, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
wsl Issue in vscode-remote WSL
Projects
None yet
Development

No branches or pull requests

6 participants