Skip to content

path seems not to be inherited when spawning git #181

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

Open
richard-ling opened this issue Oct 21, 2019 · 3 comments
Open

path seems not to be inherited when spawning git #181

richard-ling opened this issue Oct 21, 2019 · 3 comments

Comments

@richard-ling
Copy link

Hi, first up, thanks for this awesome idea -- I only found patch-package a couple of days ago and I'm already in love! Simple but so useful. I'm looking forward to removing lots of forked dependencies from my repo in coming days!

I'm on a Mac, and when I first asked patch-package to create a patch, I got a strange error:

xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.

This is the output from /usr/bin/git, which is a small stub on Macs that asks the user to install Xcode. I already have the full git suite installed, and on my $PATH at /usr/local/bin/git, and I use VS Code, so I don't want to install Xcode too.

I found that if I change this line in makePatch.js

env: { HOME: tmpRepo.name },

to

env: { ...process.env, HOME: tmpRepo.name },

patch-package started running the correct version of git, and was able to create a patch.

I think the unchanged line might discard all existing environment variables in the spawned process, including $PATH. But I don't know how to be sure, because I can't spawn 'set' (it's a built-in) and if I spawn a sub-shell like 'bash -c set', it picks up the correct path from .bashrc.

Needless to say, after getting this working, I used patch-package to patch itself :-D

If you think this is not a bug please feel free to ignore me, it may just be something is weird or broken on my system! Thanks again

@ds300
Copy link
Owner

ds300 commented Oct 21, 2019

Needless to say, after getting this working, I used patch-package to patch itself :-D

haha yesss ❤️

this change makes sense, I'll fix it soon. Thanks for the report! 🙏

@chpio
Copy link
Contributor

chpio commented Apr 6, 2020

yeap having the same problem on nixos, which puts all custom executables in $PATH

it seem to work for the other executables like npm, maybe it's because i have them installed through nix-shell, but git in my user profile? This fix might also be useful for the other executables too.

@ds300 could you release this fix please?

chpio added a commit to chpio/patch-package that referenced this issue Apr 14, 2020
@chpio
Copy link
Contributor

chpio commented Aug 11, 2020

fix is merged, but not released. yet

and much worse: you can't just use a fixed github dependency of patch-package:

rimraf dist/**/*.test.js

sh: rimraf: command not found

wouldn't a npmignore entry do just the same, without that dep?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants