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

Use path_helper in user shell in darwin #29864

Closed
wants to merge 1 commit into from
Closed

Conversation

joaomoreno
Copy link
Member

Fixes #21655

@idan
Copy link

idan commented Jul 23, 2017

Managed to work around the build issues with NPM5 and get a copy of this branch running via ./scripts/code.sh. I rebased onto master before building with ./scripts/npm.sh install

The flowtype extension executes without complaint and without needing to launch vscode from inside a terminal whose CWD is the project directory. I manually instrumented the flowtype extension here to log the process.env.PATH and it appears to include everything. 🎉 🎉 🎉 ✨ 🍰

However, this is still an instance of vscode launched from inside a terminal. I wracked my brains trying to figure out how to produce a double-clickable build from the instructions to no avail. gulp vscode-darwin succeeds but the resulting binary at .build/electron/Code - OSS.app opens up a generic electron window like this:

2017-07-23 at 15 13

Attempting to drop various promising-looking files on the DnD target didn't yield anything (various files in out, out-build, and out-vscode.)

Any pointers on how to test this effectively?

@joaomoreno
Copy link
Member Author

@idan If you'd like to run this build, just download it.

@isidorn isidorn modified the milestones: August 2017, July 2017 Aug 3, 2017
@joaomoreno
Copy link
Member Author

cc @idan @NinoFloris

@NinoFloris
Copy link

NinoFloris commented Aug 17, 2017

Doing a process.env in this build shows me it actually did not run? still just path defaults.

This is also very clear from the fact Ionide complains it cannot find Mono
screen shot 2017-08-17 at 19 54 31

@idan
Copy link

idan commented Aug 17, 2017 via email

@joaomoreno
Copy link
Member Author

That is odd @NinoFloris, as Code should be running path_helper as suggested in #21655. So, apparently, that doesn't fix it.

@NinoFloris
Copy link

NinoFloris commented Aug 18, 2017

it should as running path_helper from within fish shell returns a lot of info.
Probably something with the build or the call to path_helper going wrong.

I might be thick but how does getDarwinEnvironment actually return an environment from that func?

@joaomoreno
Copy link
Member Author

it should as running path_helper from within fish shell returns a lot of info.

I might be thick but how does getDarwinEnvironment actually return an environment from that func?

It doesn't launch /usr/libexec/path_helper from fish shell, it just spawns it and parses its result. Launching from within fish shell is a chicken-egg problem... if we could do that, the whole thing would be fixed.

@idan
Copy link

idan commented Aug 28, 2017

OK, so I looked at how atom is handling this, and it looks like it's the same sort of setup.

After some experimentation, it seems that the wiring of stdout is busted. When I try running path_helper like so from inside code's developer console on my machine, I get the correct $PATH:

(() => {
    const cp = require('child_process')
    const buffers = []
    const child = cp.spawn(process.env.SHELL, ['-lc', 'command /usr/libexec/path_helper'], {encoding: 'utf8', detached: true, stdio: 'pipe'})
    child.on('error', (e) => {
        console.error(e)
    })
    child.stdout.on('data', (data) => {
        buffers.push(data)
    })
    child.on('close', (code, signal) => {
        console.log(Buffer.concat(buffers).toString('utf8'))
    })
})();

The above results in output (redacted) like:

PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~ALLMYOTHERPATHENTRIES~"; export PATH;

I know that originally this used a stdio setup like ['ignore', 'pipe', process.stderr], but this led to stdout being empty.

If invoked with -i, it produces the same output, but prefixed with a block like:

begin;  function __direnv_export_eval --on-event fish_prompt; 	eval (direnv export fish); end  
 ;end <&3 3<&-
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~ALLMYOTHERPATHENTRIES~"; export PATH;

Not sure how this affects other shells yet; but at least it's showing the correct value for me, which is progress. Maybe it's a good clue on how to proceed?

@joaomoreno
Copy link
Member Author

The use of command before path_helper is interesting... I wonder what that does?

@joaomoreno
Copy link
Member Author

https://askubuntu.com/questions/512770/what-is-use-of-command-command

If you remove command from that snippet does it still work?

@joaomoreno
Copy link
Member Author

Yes, using pipe makes your setup work, but pretty much everyone else fail. We tried it and ended up reverting it: 44fcdbf

@joaomoreno
Copy link
Member Author

@idan People over at #21655 say this is no longer an issue. How about for you?

@alexdima alexdima modified the milestones: August 2017, December 2017/January 2018 Dec 12, 2017
@joaomoreno joaomoreno modified the milestones: December 2017/January 2018, Backlog Dec 15, 2017
@idan
Copy link

idan commented Dec 22, 2017

Looks good in 1.19! 😍

@joaomoreno
Copy link
Member Author

Awesome sauce.

@joaomoreno joaomoreno closed this Jan 8, 2018
@joaomoreno joaomoreno deleted the joao/path_helper branch January 8, 2018 09:48
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
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.

PATH issues with Fish shell on macOS
7 participants