twilio / twilio-cli

Unleash the power of Twilio from your command prompt
MIT License
159 stars 79 forks source link

Twilio CLI prints punycode module deprecation warning on every launch #560

Open elyscape opened 9 months ago

elyscape commented 9 months ago

Issue Summary

When installed via Homebrew, all invocations of the Twilio CLI print a deprecation error.

Steps to Reproduce

  1. Run any twilio command
  2. There is no second step

Log

$ twilio version
(node:78395) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
twilio-cli/5.16.2 darwin-arm64 node-v21.2.0

Technical Analysis

While the installation docs state that the Twilio CLI only supports Node.js 18, the Homebrew formula for the Twilio CLI depends on the node formula, which resolves to the current stable version of Node.js. At time of writing, that means version 21.2.0.

Node.js' built-in punycode module was documented as deprecated in version 7.0.0, but for version 21.0.0 the deprecation was upgraded to a runtime deprecation. As a result, any code running on Node.js 21 that imports the punycode module will cause the runtime to log a deprecation warning.

The long-term solution here is to figure out what library depends on the built-in punycode module and either get rid of it or upgrade it. However, the Homebrew formula should be updated to actually use the version of Node.js that you intend for it to support. That can be done by making it look something like this:

class Twilio < Formula
  # [...]
  depends_on "node@18"

  def install
    inreplace "bin/twilio", /^CLIENT_HOME=/, "export TWILIO_OCLIF_CLIENT_HOME=#{lib/"client"}\nCLIENT_HOME="
    libexec.install Dir["*"]
    (bin/"twilio").write_env_script libexec/"bin/twilio", PATH: "#{Formula["node@18"].opt_bin}:$PATH"
  end

  def post_install
    node = Formula["node@18"].opt_bin/"node"
    pid = spawn("#{node} #{libexec}/welcome.js")
    Process.wait pid
  end
end

Technical details:

github-actions[bot] commented 7 months ago

This issue is stale because it has been open for 30 days with no activity. Please remove stale label or comment or this issue will be closed in 30 days.

elyscape commented 7 months ago

Still present.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 30 days with no activity. Please remove stale label or comment or this issue will be closed in 30 days.

ZacharyDuBois commented 6 months ago

Still here.

mkarroqe commented 5 months ago

This is still an issue. However, I found a workaround in https://github.com/bitwarden/clients/issues/6689#issuecomment-1878884052

I didn't want to set --no-deprecation globally since I use Node at work. My temp workaround was to make an alias for bw:

# Temp workaround to disable punycode deprecation logging to stderr
# https://github.com/bitwarden/clients/issues/6689
alias bw='NODE_OPTIONS="--no-deprecation" bw'

this worked for me for the time being! thanks @kschat for this one

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 30 days with no activity. Please remove stale label or comment or this issue will be closed in 30 days.

ZacharyDuBois commented 4 months ago

Go away stale bot. An issue doesn't magically fix itself when no one replies.

tiwarishubham635 commented 4 months ago

Looking at it now

ajostergaard commented 4 months ago

IIRC I worked around this by manually installing brew install node@20 and uninstalling the version installed as a dependency using brew uninstall --ignore-dependencies node so:

brew install node@20
brew tap twilio/brew && brew install twilio
brew uninstall --ignore-dependencies node
github-actions[bot] commented 2 months ago

This issue is stale because it has been open for 30 days with no activity. Please remove stale label or comment or this issue will be closed in 30 days.

compuguy commented 2 months ago

Has this been fixed?

elyscape commented 2 months ago

@tiwarishubham635 I submitted a PR back in November that fixes this (twilio/homebrew-brew#36). It's out of date now but could be trivially updated to work. Can we get some movement on this?

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 30 days with no activity. Please remove stale label or comment or this issue will be closed in 30 days.

ajostergaard commented 1 month ago

Not stale and very annoying. Most annoying thing is that the fix is there for the taking (thanks @elyscape) but maintainers are nowhere to be seen. :( Oh and Twilio is a paid service so the gripe is warranted.

tiwarishubham635 commented 1 month ago

Hi @elyscape! Since twilio-cli has moved completly to node18, I think this change should be good to go. Can you update your PR? I have checked it and will approve it right away. Sorry for the delay everyone.

elyscape commented 1 month ago

@tiwarishubham635 PR updated.

auman66 commented 1 month ago

@elyscape - Your PR seems to have fixed it for me. I pinged @tiwarishubham635 to see if he can review and push the change. Thanks for your contribution!

tiwarishubham635 commented 1 month ago

Since the changes are pushed to homebrew repo, that should fix it. We can close this issue after the next release

github-actions[bot] commented 17 hours ago

This issue is stale because it has been open for 30 days with no activity. Please remove stale label or comment or this issue will be closed in 30 days.