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
ShellJS doesn't respect NPM Registry being set outside of it #761
Comments
@Aghassi thanks for reporting. Could you try writing a bash script and seeing if that works as expected? After that, could you try replacing your JS script with: // this is run by `yarn test`
process.chdir(project);
child_process.execSync('yarn'); Let me know if that works as expected. |
@nfischer Alright so I have run a bash script (or just a line of bash in the YAML file) and it will run I tried what you asked, still getting errors since it can't ready the registry or our https-proxy set by npm
And the script below
Question, since this is running in a Node environment, is it possible to grab the registry and https-proxy settings from the environment and pass them to ShellJS via a check before ShellJS runs? |
To clarify, you still see the wrong behavior if you use I don't know much about setting alternate registries. I assume |
Does yarn respect npm configs? You could also try running |
@nfischer Yes I see the same behavior NPM reads from from There is a pecking order. I think it is Local > User > Global. @freitagbr Yes |
Ok, so it sounds like the issue may be with node's core lib, not our module specifically. I'm out of ideas as to what is causing this, but I don't think there's any change required for shelljs (since this appears in |
@nfischer Does |
Simplest way: process.env.FOO = 'bar';
shell.exec('echo $FOO'); // shows "bar\n" |
@nfischer Just got back from a trip, let me give this a try and report back. |
@Aghassi is it safe to close this now? |
@nfischer Yeah, I never had a chance to sit down and test it out, got pulled into other things. If I run into the problem again, I will report back here. Appreciate the follow up :). |
Just in case anyone from google comes across this like I did, the problem is most likely environment variables in const { npm_config_registry, ...env } = process.env;
execSync("yarn install some-package", { env }); |
@narehart, that's a solution for a similar issue I was facing 🎉 |
Node version (or tell us if you're using electron or some other framework): 8.1.4
ShellJS version (the most recent version/Github branch you see the bug on): 0.7.8
Operating system: macOS 10.12.6
Description of the bug:
In a CI environment (CircleCI), my company is required to set both the
registry
and thehttps-proxy
of the.npmrc
file. These settings are not carried into the environmentshelljs
operates in. I know this because I start getting timeouts when trying to runyarn
ornpm install
when running viashell.exec
Example ShellJS command to reproduce the error:
I can't provide exact registries or proxies since they are internal, so I will provide the "scenario" or "conditions" under which this would happen.
And
yarn test
would run some script that hadIn this case, ShellJS's environment will not have the registry variables we set. In addition, running
-g
for the registry variables does not fix the issue. At this point, the only solution is to haveshelljs
set the registry again in the script. This defeats the purpose of setting it outside of the script.The text was updated successfully, but these errors were encountered: