twilio/twilio-cli

Twilio CLI prints punycode module deprecation warning on every launch

Opened this issue · 19 comments

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:

  • twilio-cli version: 5.16.2
  • node version: 21.2.0

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.

Still present.

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.

Still here.

This is still an issue. However, I found a workaround in bitwarden/clients#6689 (comment)

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

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.

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

Looking at it now

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

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.

Has this been fixed?

@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?

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.

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.

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 - 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!

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

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.