You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importostest=os.environ['USERNAME'] #?path=os.environ['Path'] # also failsprint(path)
Expected result: logs 'almenon'
Actual result:
In AREPL I avoid this problem by using python-shell and passing the env vars in like so:
Constructor of arepl-backend:
if(!options.env)options.env={}if(process.platform=="darwin"){// needed for Mac to prevent ENOENToptions.env.PATH=["/usr/local/bin",process.env.PATH].join(":")}elseif(process.platform=="win32"){// needed for windows for encoding to match what it would be in terminal// https://docs.python.org/3/library/sys.html#sys.stdinoptions.env.PYTHONIOENCODING="utf8"}
// basically all this does is load a file.. why does it need to be async *sob*constenv=awaitthis.loadAndWatchEnvVars()this.PythonEvaluator=newPythonEvaluator({
pythonOptions,
pythonPath,
env,})
The python extension code has the benefit of also reading from the workspace .env file. The downside is that it is very large and complex, probably overengineered IMO.
The text was updated successfully, but these errors were encountered:
Almenon
changed the title
env vars don't work
wolf runs into error with env vars
Nov 26, 2020
I took a look in the code in #54 - did this fix the problem when you tested it? I think you would still have the same issue - the environment vars you pass in just has the PATH in darwin OS's but it should have the USERNAME and other env vars too.
And you were 100% right :D I really don't know how it got passed the unit tests to begin with (local pytest cache maybe?), merging in process.env was the magic bit.
PS: Really good to hear from you again old friend :)
Uh oh!
There was an error while loading. Please reload this page.
Python code:
Expected result: logs 'almenon'

Actual result:
In AREPL I avoid this problem by using python-shell and passing the env vars in like so:
Constructor of arepl-backend:
In start() method in backend:
https://github.com/Almenon/AREPL-backend/blob/209eb5b8ae8cda1677f925749a10cd263f6d9860/index.ts#L171
In arepl-vscode I borrowed some code from the python extension, adapted it a bit and hardcoded it into a folder called "env": https://github.com/Almenon/AREPL-vscode/tree/7ed81bd83b8b30b1d18366c7f1254b13b6dc6ba6/src/env
Then in https://github.com/Almenon/AREPL-vscode/blob/d8c9f32d573213163f27e903e31df197be1e8248/src%2FPreviewManager.ts#L5 I have:
The python extension code has the benefit of also reading from the workspace .env file. The downside is that it is very large and complex, probably overengineered IMO.
The text was updated successfully, but these errors were encountered: