Skip to content

workerLib's spawn should preserve the environment #677

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

Merged
merged 2 commits into from
Oct 22, 2015

Conversation

Ptival
Copy link
Contributor

@Ptival Ptival commented Oct 21, 2015

Hello,

Working on NixOS, it is extremely bad that atom-typescript overwrites the environment of the process when calling spawn.
In particular, the child process fails to spawn as it cannot find libgtk-x11.

This patch attempts to solve this issue by only overriding the existing environment.

What is the policy with regards to pull requests? I notice the dist/ repository is tracked, which is weird, but I guess it's useful for bootstrapping?

Best regards,

@basarat basarat self-assigned this Oct 22, 2015
@@ -231,10 +231,16 @@ export class Parent extends RequesterResponder {
/** start worker */
startWorker(childJsPath: string, terminalError: (e: Error) => any, customArguments: string[]) {
try {
var spawnEnv = process.env;
spawnEnv['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = '1';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issues:

a.) You are mutating process.env here ... that is bad
b.) Using process.env as a whole breaks using atom as node on windows. See : atom/atom#2887 (comment) and independently verified : atom/atom#2887 (comment)

Solutions :

  • Use Object.create around process.env
  • only do if platform is NixOS

Thanks for finding the bug 🌹

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, oops! I will fix that.

Do you have an existing way of checking the operating system?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an existing way of checking the operating system?

process.platform https://nodejs.org/api/process.html#process_process_platform although I don't know the value for NixOS .... I'd be okay with whatever that is as long as its not mac / windows :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has value 'linux' under NixOS.
I can set it that way, though I am not able to test on many such operating systems.

@basarat
Copy link
Member

basarat commented Oct 22, 2015

What is the policy with regards to pull requests? I notice the dist/ repository is tracked, which is weird, but I guess it's useful for bootstrapping?

Its because atom packages are git tags ... and if the .js resources aren't there in github package will not work :-/ :rose:

basarat added a commit that referenced this pull request Oct 22, 2015
workerLib's spawn should preserve the environment
@basarat basarat merged commit 9ba9169 into TypeStrong:master Oct 22, 2015
basarat added a commit that referenced this pull request Oct 22, 2015
@basarat
Copy link
Member

basarat commented Oct 22, 2015

Released as a minor update : https://github.com/TypeStrong/atom-typescript/releases/tag/v7.5.0 🌹

@TypeStrong TypeStrong locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants