bitwarden-alfred-workflow
bitwarden-alfred-workflow copied to clipboard
Error "The `punycode` module is deprecated."
Once again, the workflow stopped working. When I retrieve a password and paste it into the password field of the website or whatever, it telle me the password is wrong. Took me a while to figure put that what I'm pasting is not actually the password for the selected item but literally login.password
. (It would be great if the workflow could produce an error when it is not receiving the password as intended. But that only as an aside.)
So I started to investigate what's going on and found that when I try to retrieve a password, the log ends like this:
},
"variables": {
"action": "-getitem",
"action2": "-id e0322606-d52a-4cf7-8e07-adbb01064969",
"action3": " ",
"notification": "Copy Password for user:\n20130000-0000"
},
"mods": {
"alt": {
"arg": "20130000-0000",
"subtitle": "Copy [truncated]
Not sure what or why it is getting truncated, but that is definitely not the item I selected but a completely unrelated.
It reminds me of the problem with the MAX_RESULTS
(#177) but I have already set MAX_results tp 5000.
I tried logging in again (although I believe I already was logged in) an that gives me this error:
It says: The punycode
module is deprecated. Please use a userland alternative instead. (Use node --trace-deprecation ...
to show where the warning was created) `
Is the workflow broken or am I doing something wrong?
Looks like this is a bug in the cli: https://github.com/bitwarden/clients/issues/6689
How can I set the NODE_OPTIONS="--no-deprecation"
in the workflow?
Have you tried to set it directly as an environment variable of the Alfred Workflow? Not sure right now if it's passed down to the go binary. Otherwise you could try to set it and export it in the script part of the workflow where the binary is called.
I tried but I'm not sure whether I did it the right way:
As for adding it to a script: I wouldn't know which script to add it to...
@tophee It should look like this
I tried that but it doesn't fix the issue.
Edit: I followed the instructions here, but npm install --global @bitwarden/[email protected]
fails for me:
% npm install --global @bitwarden/[email protected]
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
npm WARN deprecated [email protected]: Use your platform's native atob() and btoa() methods instead
npm WARN deprecated @koa/[email protected]: **IMPORTANT 10x+ PERFORMANCE UPGRADE**: Please upgrade to v12.0.1+ as we have fixed an issue with debuglog causing 10x slower router benchmark performance, see https://github.com/koajs/router/pull/173
npm WARN deprecated [email protected]: Use your platform's native DOMException instead
npm ERR! code EEXIST
npm ERR! path /opt/homebrew/bin/bw
npm ERR! EEXIST: file already exists
npm ERR! File exists: /opt/homebrew/bin/bw
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
I then tried --force
but that completely broke bw
:
% npm install --force --global @bitwarden/[email protected]
npm WARN using --force Recommended protections disabled.
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
npm WARN deprecated [email protected]: Use your platform's native atob() and btoa() methods instead
npm WARN deprecated @koa/[email protected]: **IMPORTANT 10x+ PERFORMANCE UPGRADE**: Please upgrade to v12.0.1+ as we have fixed an issue with debuglog causing 10x slower router benchmark performance, see https://github.com/koajs/router/pull/173
npm WARN deprecated [email protected]: Use your platform's native DOMException instead
npm ERR! code 1
npm ERR! path /opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/argon2
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! CC(target) Release/obj.target/libargon2/argon2/src/ref.o
npm ERR! CC(target) Release/obj.target/libargon2/argon2/src/argon2.o
npm ERR! CC(target) Release/obj.target/libargon2/argon2/src/core.o
npm ERR! CC(target) Release/obj.target/libargon2/argon2/src/blake2/blake2b.o
npm ERR! CC(target) Release/obj.target/libargon2/argon2/src/thread.o
npm ERR! CC(target) Release/obj.target/libargon2/argon2/src/encoding.o
npm ERR! LIBTOOL-STATIC Release/argon2.a
npm ERR! Failed to execute '/opt/homebrew/Cellar/node/21.1.0/bin/node /opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/argon2/lib/binding/napi-v3/argon2.node --module_name=argon2 --module_path=/opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/argon2/lib/binding/napi-v3 --napi_version=9 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using [email protected]
npm ERR! node-pre-gyp info using [email protected] | darwin | arm64
npm ERR! (node:81840) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
npm ERR! node-pre-gyp info check checked for "/opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/argon2/lib/binding/napi-v3/argon2.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/ranisalt/node-argon2/releases/download/v0.31.0/argon2-v0.31.0-napi-v3-darwin-arm64-unknown.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/ranisalt/node-argon2/releases/download/v0.31.0/argon2-v0.31.0-napi-v3-darwin-arm64-unknown.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v120 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/ranisalt/node-argon2/releases/download/v0.31.0/argon2-v0.31.0-napi-v3-darwin-arm64-unknown.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info find Python using Python version 3.11.6 found at "/Users/hauch/anaconda3/bin/python3"
npm ERR! gyp info spawn /Users/hauch/anaconda3/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/argon2/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/hauch/Library/Caches/node-gyp/21.1.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/hauch/Library/Caches/node-gyp/21.1.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/hauch/Library/Caches/node-gyp/21.1.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/argon2',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! error: libtool: file: Release/obj.target/libargon2/argon2/src/ref.o is not an object file (not allowed in a library)
npm ERR! error: libtool: file: Release/obj.target/libargon2/argon2/src/argon2.o is not an object file (not allowed in a library)
npm ERR! error: libtool: file: Release/obj.target/libargon2/argon2/src/core.o is not an object file (not allowed in a library)
npm ERR! error: libtool: file: Release/obj.target/libargon2/argon2/src/blake2/blake2b.o is not an object file (not allowed in a library)
npm ERR! error: libtool: file: Release/obj.target/libargon2/argon2/src/thread.o is not an object file (not allowed in a library)
npm ERR! error: libtool: file: Release/obj.target/libargon2/argon2/src/encoding.o is not an object file (not allowed in a library)
npm ERR! make: *** [Release/argon2.a] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:515:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm ERR! gyp ERR! System Darwin 23.1.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/21.1.0/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/argon2/lib/binding/napi-v3/argon2.node" "--module_name=argon2" "--module_path=/opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/argon2/lib/binding/napi-v3" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
npm ERR! gyp ERR! cwd /opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/argon2
npm ERR! gyp ERR! node -v v21.1.0
npm ERR! gyp ERR! node-gyp -v v9.4.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/opt/homebrew/Cellar/node/21.1.0/bin/node /opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/argon2/lib/binding/napi-v3/argon2.node --module_name=argon2 --module_path=/opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/argon2/lib/binding/napi-v3 --napi_version=9 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack at ChildProcess.emit (node:events:515:28)
npm ERR! node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1105:16)
npm ERR! node-pre-gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:305:5)
npm ERR! node-pre-gyp ERR! System Darwin 23.1.0
npm ERR! node-pre-gyp ERR! command "/opt/homebrew/Cellar/node/21.1.0/bin/node" "/opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /opt/homebrew/lib/node_modules/@bitwarden/cli/node_modules/argon2
npm ERR! node-pre-gyp ERR! node -v v21.1.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.11
npm ERR! node-pre-gyp ERR! not ok
npm ERR! A complete log of this run can be found in: /Users/hauch/.npm/_logs/2023-12-08T09_49_56_286Z-debug-0.log
I tried using homebrew instead:
brew remove bitwarden-cli
and then
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/55684f248ec24823bd53335c341dbf95cfac6b77/Formula/b/bitwarden-cli.rb > bitwarden-cli.rb
and
brew install bitwarden-cli.rb
but the workflos still doesn't work (can't login).
@tophee I gave up a long time ago trying to manage node/npm with Homebrew. It's a mess of dependencies, conflicts and permission issues. I suggest you try some variation of:
- remove the Homebrew version:
brew uninstall bitwarden-cli
- install node/npm from the pkg: https://nodejs.org/en/download/ (will install node at
/usr/local/{bin,lib}
) - fix permissions:
sudo chown -R $(id -un):$(id -gn) /usr/local
- reset your
$PATH
prior to running the install command to override Homebrew'snode
export PATH=$(sysctl -n user.cs_path):/usr/local/bin
- reinstall bw cli:
/usr/local/bin/npm -g install @bitwarden/[email protected]
- change
BW_EXEC
variable in the workflow to point at/usr/local/bin/bw
Then retry the steps in the other fix...
@tophee Did that work for you?
Wow! Thank you so much for taking the time to explain this! It looks like it worked even though I got
> sudo chown -R $(id -un):$(id -gn) /usr/local (base)
Password:
chown: /usr/local: Operation not permitted
I just continued with the other steps and the workflow is working again!
Now, just to clarify where we stand with this downgrading fix (and bitwarden and npm no longer handled by homebrew): how do I know when I can upgrade to the latest bitwarden-cli? And once it is time to upgrade, I assume I just do /usr/local/bin/npm -g upgrade @bitwarden/cli
or something like that?
I'm also unsure what consequences it might have that npm is no longer managed by homebrew. (I am not a developer and using homebrew has so far been a way of not having to understand much of various package dependencies etc. So, no that npm is separate, what do I need to be aware of? Maybe just run something like npm update
every now and then, just like I do brew upgrade
every couple of months or so?
If you got an Operation not permitted
error when running chown
, you may have either entered your password incorrectly, or the account you're using on that Mac isn't an admin.
That command isn't critical, if the workflow is working again for you then it seems that npm had the necessary permissions to create its files at /usr/local. So no need to worry about it.
As to the other questions, you probably still have node installed via Homebrew (it's required by a lot of packages), so this particular instance of it is really only used temporarily so we could install and manage a custom version of the Bitwarden CLI. It should not cause any other issues with Homebrew or npm for you, as long as you don't have /usr/local/bin
in your $PATH
before /opt/homebrew
.
I would keep an eye on these GitHub pages to know when it's "safe" to unwind the workaround and go back to the brew-managed version of bw
:
- BUG: CLI list item error · Issue #7126 · bitwarden/clients
- [PM-5177] fix CLI list items lock error by bxb100 · Pull Request #7133 · bitwarden/clients
- Releases · bitwarden/clients
I'll definitely post back here and update #186 as well once there's a better workaround or a fixed version is posted.
So, I tried installing the correct CLI version as described in here, and adding -no-depreciation... But it still won't login for me..
Processing complete Bitwarden v2[Run Script] Passing output 'Unexpected error. Exit code 9. Has the session key changed? [ERROR] node: --no-depreciation is not allowed in NODE_OPTIONS' to Conditional Bitwarden v2[Conditional] Processing complete Bitwarden v2[Conditional] Passing output 'Unexpected error. Exit code 9. Has the session key changed? [ERROR] node: --no-depreciation is not allowed in NODE_OPTIONS' to Post Notification
For reference, I'm using NVM and have version 20.10.0 installed.
@MikeAg03 the flag is --no-deprecation
(not depreciation)
@MikeAg03 the flag is
--no-deprecation
(not depreciation)
Thanks, that resolved it! I need to read better! :)
v2023.12.1 was just released, and seems to fix the issue.
npm uninstall --global @bitwarden/cli
npm install --global @bitwarden/[email protected]
(You can remove the NODE_OPTIONS="--no-deprecation"
from the workflow as well.)
The second command gave me a long list of errors. I saw that there were some homebrew paths involved in those error messages, so I repeated what you said above
- reset your $PATH prior to running the install command to override Homebrew's node export PATH=$(sysctl -n user.cs_path):/usr/local/bin
This didn't work in fish
in iTerm but when I changed to the Apple terminal, it worked (even though that is also using fish
). I have no idea how to make sense of this, but now bw -v
gves me 2023.12.1
, so I assume that it works.
I should probably switch back to the homebrew version, right?
If you want the automatic updates then yes switching back to the Homebrew version is simpler.
Regression in 2024.1.0? At least this problem arises again to me
I don't know whether it's a regression or what is wrong but something is not working properly, also with 2024.2.1. I tried a lot of things for over an hour (makes no sense, I know, but I can't let go of this kind of stuff) and eventually I got it to work again. (still using the homebrew version, so switching to npm is not necessary this time).
I don't know whether it's a regression or what is wrong but something is not working properly, also with 2024.2.1. I tried a lot of things for over an hour (makes no sense, I know, but I can't let go of this kind of stuff) and eventually I got it to work again. (still using the homebrew version, so switching to npm is not necessary this time).
Do you know the changes to make it work properly?
@imyelmo Sorry, no, I tried so many things that may or may not have interfered with each other (such also logging into bitwarden via the cli, clearing or not clearing the workflow cache, logging out etc) that I really can't tell what fixed it. My suspicion is that it boils down to adding that no-deprecation setting as described above.