{"action":"created","issue":{"url":"https://api.github.com/repos/pyinvoke/invoke/issues/259","labels_url":"https://api.github.com/repos/pyinvoke/invoke/issues/259/labels{/name}","comments_url":"https://api.github.com/repos/pyinvoke/invoke/issues/259/comments","events_url":"https://api.github.com/repos/pyinvoke/invoke/issues/259/events","html_url":"https://github.com/pyinvoke/invoke/issues/259","id":94254056,"number":259,"title":"Ability to specify environment variables to be used with the run function","user":{"login":"fgimian","id":1811813,"avatar_url":"https://avatars.githubusercontent.com/u/1811813?v=3","gravatar_id":"","url":"https://api.github.com/users/fgimian","html_url":"https://github.com/fgimian","followers_url":"https://api.github.com/users/fgimian/followers","following_url":"https://api.github.com/users/fgimian/following{/other_user}","gists_url":"https://api.github.com/users/fgimian/gists{/gist_id}","starred_url":"https://api.github.com/users/fgimian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fgimian/subscriptions","organizations_url":"https://api.github.com/users/fgimian/orgs","repos_url":"https://api.github.com/users/fgimian/repos","events_url":"https://api.github.com/users/fgimian/events{/privacy}","received_events_url":"https://api.github.com/users/fgimian/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pyinvoke/invoke/labels/Feature","name":"Feature","color":"40a056"},{"url":"https://api.github.com/repos/pyinvoke/invoke/labels/Needs%20patch","name":"Needs patch","color":"fef2c0"},{"url":"https://api.github.com/repos/pyinvoke/invoke/labels/Needs%20review","name":"Needs review","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-07-10T08:51:57Z","updated_at":"2015-07-15T00:16:06Z","closed_at":null,"body":"Hey there, love invoke.\r\n\r\nIn fabric, we have `with shell_env(...)` so that a particular set of environment variables will be used in a particular scope, which apply to commands being run.\r\n\r\nIs there any way to currently accomplish this with invoke?\r\n\r\nI would really love to switch back to it, but I've reluctantly switched to paver until I can figure this out.\r\n\r\nThanks\r\nFotis"},"comment":{"url":"https://api.github.com/repos/pyinvoke/invoke/issues/comments/121433456","html_url":"https://github.com/pyinvoke/invoke/issues/259#issuecomment-121433456","issue_url":"https://api.github.com/repos/pyinvoke/invoke/issues/259","id":121433456,"user":{"login":"bitprophet","id":6088,"avatar_url":"https://avatars.githubusercontent.com/u/6088?v=3","gravatar_id":"","url":"https://api.github.com/users/bitprophet","html_url":"https://github.com/bitprophet","followers_url":"https://api.github.com/users/bitprophet/followers","following_url":"https://api.github.com/users/bitprophet/following{/other_user}","gists_url":"https://api.github.com/users/bitprophet/gists{/gist_id}","starred_url":"https://api.github.com/users/bitprophet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitprophet/subscriptions","organizations_url":"https://api.github.com/users/bitprophet/orgs","repos_url":"https://api.github.com/users/bitprophet/repos","events_url":"https://api.github.com/users/bitprophet/events{/privacy}","received_events_url":"https://api.github.com/users/bitprophet/received_events","type":"User","site_admin":false},"created_at":"2015-07-15T00:16:06Z","updated_at":"2015-07-15T00:16:06Z","body":"Hrm, I'm confused by the stdlib right now, here's the skinny:\r\n\r\n* In the past we used `subprocess` to run things and I am 99% sure that definitely honors the current environment.\r\n* We recentlyish switched to `os.execv` and while that also *claims* it supports modifications to `os.environ` (as per https://docs.python.org/2.6/library/os.html#os.environ and https://docs.python.org/2.6/library/os.html#os.putenv) I'm wondering if there is a bug or other different behavior here.\r\n* Also of note is that we *should* be able to leverage `os.execve` and friends (https://docs.python.org/2.6/library/os.html#os.execve) to specify a \"clean\" env, presumably irrespective of the contents of `os.environ` and the current confusion about whether it's honored by default."}}