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

pnpm and npm should not be merged in the same command #68

Closed
TommasoAmici opened this issue Oct 24, 2022 · 11 comments · Fixed by #114
Closed

pnpm and npm should not be merged in the same command #68

TommasoAmici opened this issue Oct 24, 2022 · 11 comments · Fixed by #114

Comments

@TommasoAmici
Copy link

What did you expect to happen?

I have both npm and pnpm installed, I use npm for global installs and pnpm for projects.

I upgraded topgrade and since this commit 27349b1 it's now using pnpm for global upgrades.

pnpm should not be considered an alternative to npm as most users will have both installed (I don't think you can actually have pnpm and not have npm)

Additionally, topgrade created a ~ directory in my HOME directory with empty Library/pnpm directories

image

Additional Details

  • Which operating system or Linux distribution are you using? Not relevant
  • How did you install Topgrade? Not relevant
  • Which version are you running?
    Topgrade 10.0.0
―― 09:57:13 - Node Package Manager ―――――――――――――――――――――――――――――――――――――――――――――
Dry running: /opt/homebrew/bin/pnpm update -g

This should remain as npm update -g

@s34m
Copy link
Member

s34m commented Oct 24, 2022

At first, which OS are you using?

Second, how do you let pnpm just update local packages?

Third, what's the difference between running pnpm globally and running globally

Fourth, this would probably just turn out to be a config setting like npm_global=bool, pnpm_global=bool

@raszi
Copy link

raszi commented Oct 26, 2022

I ran into a similar issue. I have npm working properly for global packages, but pnpm is not, I never used it but for other reasons (it comes with the corepack package), I have that installed in my global packages, but it isn't working for me:

➜  ~ npm outdated -g 
➜  ~ pnpm outdated -g
 ERROR  Unable to find the global bin directory
Run "pnpm setup" to create it automatically, or set the global-bin-dir setting, or the PNPM_HOME env variable. The global bin directory should be in the PATH.

I would like to have a way to configure what should be the preferred way to update Node packages and topgrade should not try to figure that out on its own, because it cannot.

@TommasoAmici
Copy link
Author

Let's backtrack a little bit. When installing nodejs, it comes with its default package manager npm.

npm will always be installed, there are no two ways around it. However, developers have the option to use different package managers for node/js projects. The two most common ones are yarn and pnpm.

For all intents and purposes, when it comes to topgrade, yarn and pnpm should be treated it in the same way.

In topgrade yarn has its own separate step, it's not a replacement for npm and pnpm should behave in the same way.

If you're familiar with python, maybe this analogy can help: pip=npm, poetry=yarn/pnpm

At first, which OS are you using?

macOS 12

Third, what's the difference between running pnpm locally and running globally

This is the same difference as using cargo install for a global binary or using cargo in the context of a rust project:

# this will install xxx globally on your machine and add the binary to PATH
pnpm install --global xxx
# this will check that your project has a package.json and will add the dependency locally
pnpm install xxx

Second, how do you let pnpm just update local packages?

pnpm update docs: https://pnpm.io/cli/update

@Morl99
Copy link

Morl99 commented Oct 26, 2022

This used to be a separate step that we could disable with disable=["pnpm"], was there a specific reason to remove this separate step? For me that worked well, because I was in control. See the original issue in the old repo for references.

@Jackenmen
Copy link

This also makes the step completely fail for me now as I apparently have pnpm installed (I've probably installed it when installing yarn with corepack) but never configured it. What's interesting is that topgrade doesn't show any error at all when running normally:

❯ topgrade --only node        

Retry? (y)es/(N)o/(s)hell/(q)uit

―― 15:45:37 - Yarn Package Manager ―――――――――――――――――――――――――――――――――――――――――――――
...

―― 15:45:40 - Summary ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
npm: FAILED
yarn: OK
❯ topgrade --only node --dry-run

Retry? (y)es/(N)o/(s)hell/(q)uit

―― 15:46:01 - Yarn Package Manager ―――――――――――――――――――――――――――――――――――――――――――――
Dry running: /usr/local/bin/yarn global upgrade

―― 15:46:01 - Summary ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
npm: FAILED
yarn: OK

I can only get any information about this failure when running topgrade with -v flag:

❯ topgrade --only node --dry-run -v
 2022-10-26T13:46:17.085Z DEBUG topgrade::config > Configuration at /home/ubuntu/.config/topgrade.toml
 2022-10-26T13:46:17.086Z DEBUG topgrade::config > Loaded configuration: ConfigFile { pre_commands: Some({}), post_commands: None, commands: Some({"nix": "sudo nix-channel --update && sudo nix-env --upgrade", "pipx": "sudo pipx upgrade-all", "virtualenv-embed-wheels": "virtualenv --upgrade-embed-wheels"}), git_repos: None, predefined_git_repos: None, disable: Some([Chezmoi, Nix, Pipx, Pip3]), ignore_failures: None, remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, git_arguments: None, tmux_arguments: None, set_title: None, display_time: None, assume_yes: None, yay_arguments: None, aura_aur_arguments: None, aura_pacman_arguments: None, no_retry: None, run_in_tmux: None, cleanup: None, notify_each_step: None, accept_all_windows_updates: None, skip_notify: None, bashit_branch: None, only: None, composer: Some(Composer { self_update: None }), brew: Some(Brew { greedy_cask: None, autoremove: None }), linux: Some(Linux { yay_arguments: None, aura_aur_arguments: None, aura_pacman_arguments: None, arch_package_manager: None, show_arch_news: None, trizen_arguments: None, pikaur_arguments: None, pamac_arguments: None, dnf_arguments: None, apt_arguments: None, enable_tlmgr: None, redhat_distro_sync: None, rpm_ostree: None, emerge_sync_flags: None, emerge_update_flags: None }), git: Some(Git { max_concurrency: None, arguments: None, repos: None, pull_predefined: None }), windows: Some(Windows { accept_all_updates: None, self_rename: None, open_remotes_in_new_terminal: None, enable_winget: None }), npm: Some(NPM { use_sudo: None }), yarn: None, vim: None, firmware: Some(Firmware { upgrade: None }), vagrant: None, flatpak: Some(Flatpak { use_sudo: None }) }
 2022-10-26T13:46:17.086Z DEBUG topgrade::utils  > Detected "/usr/bin/notify-send" as "notify-send"
 2022-10-26T13:46:17.086Z DEBUG topgrade         > Version: 10.0.1
 2022-10-26T13:46:17.086Z DEBUG topgrade         > OS: x86_64-unknown-linux-gnu
 2022-10-26T13:46:17.086Z DEBUG topgrade         > Args { inner: ["topgrade", "--only", "node", "--dry-run", "-v"] }
 2022-10-26T13:46:17.086Z DEBUG topgrade         > Binary path: Ok("/home/ubuntu/.cargo/bin/topgrade")
 2022-10-26T13:46:17.086Z DEBUG topgrade         > Self Update: false
 2022-10-26T13:46:17.086Z DEBUG topgrade::utils  > Detected "/usr/bin/git" as "git"
 2022-10-26T13:46:17.086Z DEBUG topgrade::utils  > Cannot find "doas"
 2022-10-26T13:46:17.086Z DEBUG topgrade::utils  > Detected "/usr/bin/sudo" as "sudo"
 2022-10-26T13:46:17.086Z DEBUG topgrade::utils  > Cannot find "pwsh"
 2022-10-26T13:46:17.086Z DEBUG topgrade::utils  > Cannot find "powershell"
 2022-10-26T13:46:17.087Z DEBUG topgrade::utils  > Path "/home/ubuntu/.config/emacs" doesn't exist
 2022-10-26T13:46:17.087Z DEBUG topgrade::utils  > Path "/home/ubuntu/.emacs.d" doesn't exist
 2022-10-26T13:46:17.087Z DEBUG topgrade::steps::git > /home/ubuntu/.ideavimrc does not exists
 2022-10-26T13:46:17.087Z DEBUG topgrade::steps::git > /home/ubuntu/.intellimacs does not exists
 2022-10-26T13:46:17.087Z DEBUG topgrade::steps::git > /home/ubuntu/.zshrc is a file. Checking /home/ubuntu
 2022-10-26T13:46:17.087Z DEBUG topgrade::steps::git > Checking if /home/ubuntu is a git repository
 2022-10-26T13:46:17.089Z TRACE topgrade::executor   > Output of "/usr/bin/git" "rev-parse" "--show-toplevel": Output { status: ExitStatus(unix_wait_status(32768)), stdout: "", stderr: "fatal: not a git repository (or any parent up to mount point /)\nStopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\n" }
 2022-10-26T13:46:17.089Z DEBUG topgrade::steps::git > /home/ubuntu/.config/fish does not exists
 2022-10-26T13:46:17.089Z DEBUG topgrade::steps::git > /home/ubuntu/.config/openbox does not exists
 2022-10-26T13:46:17.089Z DEBUG topgrade::steps::git > /home/ubuntu/.config/bspwm does not exists
 2022-10-26T13:46:17.089Z DEBUG topgrade::steps::git > /home/ubuntu/.config/i3 does not exists
 2022-10-26T13:46:17.089Z DEBUG topgrade::steps::git > /home/ubuntu/.config/sway does not exists
 2022-10-26T13:46:17.089Z DEBUG topgrade::runner     > Step "npm"
 2022-10-26T13:46:17.089Z DEBUG topgrade::utils      > Detected "/usr/local/bin/pnpm" as "pnpm"
 2022-10-26T13:46:17.242Z TRACE topgrade::executor   > Output of "/usr/local/bin/pnpm" "--version": Output { status: ExitStatus(unix_wait_status(0)), stdout: "7.14.0\n", stderr: "" }
 2022-10-26T13:46:17.627Z TRACE topgrade::executor   > Output of "/usr/local/bin/pnpm" "root" "-g": Output { status: ExitStatus(unix_wait_status(256)), stdout: "\u{2009}ERROR\u{2009} Unable to find the global bin directory\nRun \"pnpm setup\" to create it automatically, or set the global-bin-dir setting, or the PNPM_HOME env variable. The global bin directory should be in the PATH.\n", stderr: "" }
 2022-10-26T13:46:17.627Z DEBUG topgrade::runner     > Step "npm" failed: exit status: 1: 
 2022-10-26T13:46:17.627Z DEBUG topgrade::terminal   > Desktop notification: npm failed

Retry? (y)es/(N)o/(s)hell/(q)uit
 2022-10-26T13:46:18.954Z DEBUG topgrade::runner     > Step "yarn"
 2022-10-26T13:46:18.954Z DEBUG topgrade::utils      > Detected "/usr/local/bin/yarn" as "yarn"
 2022-10-26T13:46:18.954Z DEBUG topgrade::utils      > Detected "/usr/local/bin/yarn" as "yarn"
 2022-10-26T13:46:19.191Z TRACE topgrade::executor   > Output of "/usr/local/bin/yarn" "global" "dir": Output { status: ExitStatus(unix_wait_status(0)), stdout: "/home/ubuntu/.config/yarn/global\n", stderr: "" }

―― 15:46:19 - Yarn Package Manager ―――――――――――――――――――――――――――――――――――――――――――――
Dry running: /usr/local/bin/yarn global upgrade

―― 15:46:19 - Summary ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
npm: FAILED
yarn: OK
 2022-10-26T13:46:19.191Z DEBUG topgrade::terminal   > Desktop notification: Topgrade finished with errors

@s34m
Copy link
Member

s34m commented Oct 26, 2022

Does someone want to fix this issue because their seems to be a lot of activity around it. Else I will do it.

@kothavade
Copy link

kothavade commented Oct 28, 2022

Working on moving pnpm to its own step, similarly to r-darwish/topgrade#963, it should be able to be enabled/disabled manually.

In my initial commit I made the assumption that anyone using pnpm would use it to completely replace npm, now you can use them interchangeably.

(My current local version still doesn't work, will send a PR when it is)

@s34m
Copy link
Member

s34m commented Oct 28, 2022

Thanks for doing the work.

@s34m
Copy link
Member

s34m commented Nov 2, 2022

@vedkothavade any updates on your local version?

@kothavade
Copy link

@vedkothavade any updates on your local version?

Been pretty busy this week with college applications, will try to finish this weekend

pan93412 added a commit to pan93412/topgrade that referenced this issue Nov 2, 2022
We reuse the `NPM` structure, and use
NPMVariant to distinguish “npm” and “pnpm”.
Besides, we also decouple the name display
from `NPM` structure.

BREAKING CHANGES: `pnpm` is now a separated step.

This fixes topgrade-rs#68.
pan93412 added a commit to pan93412/topgrade that referenced this issue Nov 2, 2022
We reuse the `NPM` structure, and use
NPMVariant to distinguish “npm” and “pnpm”.
Besides, we also decouple the name display
from `NPM` structure.

BREAKING CHANGES: `pnpm` is now a separated step.

This fixes topgrade-rs#68.
pan93412 added a commit to pan93412/topgrade that referenced this issue Nov 3, 2022
We reuse the `NPM` structure, and use
NPMVariant to distinguish “npm” and “pnpm”.
Besides, we also decouple the name display
from `NPM` structure.

BREAKING CHANGES: `pnpm` is now a separated step.

This fixes topgrade-rs#68.
pan93412 added a commit to pan93412/topgrade that referenced this issue Nov 3, 2022
We reuse the `NPM` structure, and use
NPMVariant to distinguish “npm” and “pnpm”.
Besides, we also decouple the name display
from `NPM` structure.

BREAKING CHANGES: `pnpm` is now a separated step.

This fixes topgrade-rs#68.
@pan93412
Copy link
Member

pan93412 commented Nov 4, 2022

@DottoDev Seems like we can close it? Not yet, waiting for merging to master.

@s34m s34m closed this as completed Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants