-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Code on insiders started from GUI does not pick up environment variables on Linux #6110
Comments
Might also be @dbaeumer for tasks. |
Checked and the task runner merges a process.env with the provided env. Since this only seem to happend when started from the GUI I doubt that this is caused by the task runner. |
I just update vscode to 1.1.0 today and have similar problem with using vscode-eslint. Starting vscode from terminal works fine but starting from GUI (clicking on vscode icon) doesn't because vscode does not pick up |
What do you get when running the following command?
Are you sure Code is not running when launching it from the GUI? |
Code was definitely not running prior to starting from the GUI (this happened immediately after a cold boot). The output of Looking at the output, there is no discernable difference. I haven't yet updated to the latest build on this machine, so I'll double-check to make sure the problem still exists with my real tasks.json |
It seems that the |
Yes, that is the most disturbing part of this :) When my If I do nothing but change the |
Oh, and just for completeness, the behavior persists even with latest insiders build 1.1.1 commit def9e32 |
@dbaeumer Given these findings, I believe this is somewhere in the tasks framework. |
I retested and debugged the task code and it merges the environment and doesn't replace it. @nwgh just to clarify: {
// See http://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.3.2",
"command": "${env.SHELL}",
"isShellCommand": true,
"args": ["-ilc", "env"],
"options": {"cwd": "${workspaceRoot}"},
"showOutput": "always",
"tasks": [
{
"taskName": "Full Build",
"suppressTaskName": true,
"isBuildCommand": true,
}
]
} this worlks, but {
// See http://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.3.2",
"command": "env",
"isShellCommand": true,
"options": {"cwd": "${workspaceRoot}"},
"showOutput": "always",
"tasks": [
{
"taskName": "Full Build",
"suppressTaskName": true,
"isBuildCommand": true,
}
]
} doesn't. Right. |
And just to double check: the second one even works if you start vscode from a terminal where MOZCONFIG is already part of the environment. How do you set MOZCONFIG into the env in the first place? |
@dbaeumer that's all correct - first works when starting from GUI, second doesn't. Both work when starting from CLI.
I'm now wondering if this isn't getting picked up because whatever source code uses to get environment variables on linux isn't running zsh as an interactive shell (which means |
Yeah, that explains it (on linux, at least - the fact that it all works fine on os x is still a little baffling, and probably bears investigating). If I set an environment variable in |
We run whatever shell is in |
with |
@nwgh can I ask you for another favor: for the case where it doesn't work could you do the following:
|
Found the issue. Due to #1033, Code will not read the Unfortunately, that solution has a problem: the Debian and RPM packages (cc @Tyriar) set up an application shortcut which points to that cli launcher. So, when launching Code from those application shortcuts, it won't have the correct environment. We need to look into a different fix for #1033: possibly we can figure out whether we are in a |
@dbaeumer it does not exist (which I imagine you could figure out based on @joaomoreno 's latest comment) @joaomoreno woohoo! sounds like there's at least the hint of a path towards a fix for this. Thanks, everyone! The interactions on this bug have made me ❤️ code even more 😄 |
I'm not sure I understand the problem, @joaomoreno how is launching from desktop entry any different from the CLI? Would the solution be to point to the binary instead as that's probably no issue (it may be preferable even). |
When launching from the CLI, the correct env is already there. That could be one solution, but I also don't mind doing the proposed one there, since it might be better anyways just in itself. |
@nwgh does the problem go away when you change the Exec line in
Not sure if Gnome picks up on these changes immediately or if you need to nudge it somehow. |
@Tyriar yes, that appears to fix the issue, as well. |
I think changing that may also fix #6593 |
Awesome, then I'll not do anything here. 👍 |
Steps to Reproduce:
Let me expand in a way that doesn't involve steps - I use the MOZCONFIG environment variable to tell the firefox build system how to build (what compiler to use, what object directory to use, config options, etc) - this environment variable points to a file that contains the instructions for the build system. When I build from the cli, or from an instance of code started from the cli, this works fine (my environment is picked up just fine). However, when I run from an instance of code started from the GNOME app launcher, my environment is not picked up at all, causing confusion.
I have put minimal files that exhibit this behavior at https://gist.github.com/nwgh/c7b71148908bea753a78685ffad03210
From that gist,
.zshrc
should go in$HOME
,mach
should go in some directory (call itsrcdir
), and tasks.json should go insrcdir/.vscode
. Then, open code, opensrcdir
in code, and run theFull Build
task.This worked on 0.10.15-insider (my previous build on the same machine - sorry I don't have a better build to work from for bisecting).
This behavior does not happen on my mac install of the exact same version of code.
For now, I have worked around this by making my build task a shell script that invokes zsh as an interactive shell (to pick up my environment) with a script that calls the firefox build system. I could also likely work around this with os-specific properties in my tasks.json that replicates the work my shell does, or some extra layer of indirection within my mozconfig that replicates the work my shell already does (since a mozconfig is just a shell script). However, that seems... ugly, and prone to break in the future when I inevitably change something in my shell config.
The text was updated successfully, but these errors were encountered: