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

Environment variables get applied as options to any command #793

Closed
wagnerand opened this issue Feb 7, 2017 · 12 comments · Fixed by #1812
Closed

Environment variables get applied as options to any command #793

wagnerand opened this issue Feb 7, 2017 · 12 comments · Fixed by #1812

Comments

@wagnerand
Copy link
Member

Is this a bug or feature request?

This is a bug.

What is the current behavior?

I have set WEB_EXT_API_KEY and WEB_EXT_API_SECRET in my ~/.bash_profile.
Running web-ext build for any webextension project fails with the following error:
Unknown arguments: apiSecret, apiKey
When I remove the two environment variables, web-ext works fine.

What is the expected or desired behavior?

web-ext build (and other commands) should ignore environment variables they don't need.

Version information (for bug reports)

  • Firefox version: irrelevant
  • Your OS and version: MacOS 1.12.3
  • Paste the output of these commands:
node --version && npm --version && web-ext --version

v7.5.0
4.1.2
1.6.0

@kumar303
Copy link
Contributor

kumar303 commented Feb 7, 2017

oof, good catch. I'm pretty sure this has existed ever since #226 but no one else noticed. It's because those env variables are only recognized by the sign command. For other commands, our parser thinks they are env vars for unknown options.

@eight04
Copy link
Contributor

eight04 commented Apr 30, 2017

This make environment variable totally unusable... and it seems that web-ext use yargs to parse env variable (https://github.com/mozilla/web-ext/blob/master/src/program.js#L88). Should we move this to yargs or any other ideas to fix this?

@kumar303
Copy link
Contributor

kumar303 commented May 2, 2017

Oops, I should have filed an upstream bug originally. Here it is: yargs/yargs#873

fregante added a commit to npmhub/npmhub that referenced this issue May 20, 2017
@kumar303 kumar303 changed the title web-ext build fails when WEB_EXT_API_KEY is set Environment variables get applied as options to any command Aug 2, 2017
@stephenmathieson
Copy link

Any updates here? I just killed over an hour trying to figure this out.


Hack I'm using to work-around this for now:

APIKEY="$WEB_EXT_API_KEY"
APISECRET="$WEB_EXT_API_SECRET"
unset WEB_EXT_API_KEY
unset WEB_EXT_API_SECRET

# Zip the Firefox extension.
npx web-ext build --config-discovery=false

# Zip+sign (XPI) the Firefox extension.
npx web-ext sign \
  --api-key=$APIKEY \
  --api-secret=$APISECRET \
  --config-discovery=false

@Rob--W
Copy link
Member

Rob--W commented Sep 19, 2018

No updates yet. I have planned a patch to upgrade our yargs dependency to resolve some issues ( #1307 and #1327 in particular). That might or might not fix this issue.
Regardless, you should be able to set the key and secret in the config file once #1327 is resolved.

@stephenmathieson
Copy link

I'm creating these archives on CI and want to use environment variables rather than having to worry about creating a config file.

Do you have an estimate as to when the yargs dep will be updated?

@Rob--W
Copy link
Member

Rob--W commented Sep 19, 2018

Not soon, unfortunately. I ran in multiple issues when I tried to upgrade and have other higher pressing tasks that I need to work on.

@stephenmathieson
Copy link

OK, fair enough.

Perhaps adding something to the README and/or https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/web-ext_command_reference would suffice for now?

@kumar303
Copy link
Contributor

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/web-ext_command_reference

This page is editable.

@Fedcomp
Copy link

Fedcomp commented Jun 20, 2019

wow, middle of 2019 and still not fixed

Rob--W added a commit to Rob--W/FirefoxColor that referenced this issue Aug 23, 2019
One of build_and_test's commands is `npm run xpi`, which eventually runs
`web-ext build`. Because the `WEB_EXT_API_SECRET` and `WEB_EXT_API_KEY`
environment variables are currently set in CircleCI's secret environment
variables, the build breaks because `web-ext build` fails to run when
these are set: mozilla/web-ext#793

As a work-around, unset those env vars before running `web-ext build`.
Rob--W added a commit to Rob--W/FirefoxColor that referenced this issue Aug 23, 2019
One of build_and_test's commands is `npm run xpi`, which eventually runs
`web-ext build`. Because the `WEB_EXT_API_SECRET` and `WEB_EXT_API_KEY`
environment variables are currently set in CircleCI's secret environment
variables, the build breaks because `web-ext build` fails to run when
these are set: mozilla/web-ext#793

As a work-around, unset those env vars before running `web-ext build`.
caitmuenster pushed a commit to mozilla/FirefoxColor that referenced this issue Aug 23, 2019
One of build_and_test's commands is `npm run xpi`, which eventually runs
`web-ext build`. Because the `WEB_EXT_API_SECRET` and `WEB_EXT_API_KEY`
environment variables are currently set in CircleCI's secret environment
variables, the build breaks because `web-ext build` fails to run when
these are set: mozilla/web-ext#793

As a work-around, unset those env vars before running `web-ext build`.
@bella-strange
Copy link

Just ran into this as well.

@doronbehar
Copy link

Yea this is very annoying. It's a shame this issue doesn't get any attention. It feels as if the developers aren't even using the environmental variables credentials feature so that's why it doesn't bother them.

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

Successfully merging a pull request may close this issue.

9 participants