phewsh 0.15.44 → 0.15.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/commands/update.js +18 -3
  2. package/package.json +1 -1
@@ -112,9 +112,24 @@ async function main() {
112
112
  if (code === 0) {
113
113
  console.log(` ${green('✓')} Updated to v${latest}. New shells pick it up immediately.`);
114
114
  } else {
115
- console.log(` ${yellow('Update failed')} (npm exited ${code}).`);
116
- console.log(` ${g('If it was a permissions error, fix your npm prefix or run:')}`);
117
- console.log(` ${w(`sudo npm install -g ${pkg.name}@latest`)}`);
115
+ // NEVER suggest `sudo npm i -g` — that root-owns the package dir and
116
+ // poisons every future non-sudo update (the exact trap users hit). The
117
+ // correct fix is to OWN the package, once, then update normally.
118
+ let prefix = '';
119
+ try {
120
+ prefix = require('child_process').execFileSync('npm', ['config', 'get', 'prefix'],
121
+ { encoding: 'utf-8', timeout: 3000 }).trim();
122
+ } catch { /* unknown prefix */ }
123
+ const pkgDir = prefix ? `${prefix}/lib/node_modules/${pkg.name}` : `$(npm prefix -g)/lib/node_modules/${pkg.name}`;
124
+ const binLink = prefix ? `${prefix}/bin/${pkg.name}` : `$(npm prefix -g)/bin/${pkg.name}`;
125
+ console.log(` ${yellow('Update failed')} (npm exited ${code}) — almost certainly a permissions issue.`);
126
+ console.log(` ${g('The phewsh package is probably root-owned from a past `sudo` install.')}`);
127
+ console.log(` ${b('Own it once, then updates never need sudo again:')}`);
128
+ console.log(` ${w(`sudo chown -R $(whoami) "${pkgDir}"`)}`);
129
+ console.log(` ${w(`sudo chown -h $(whoami) "${binLink}"`)}`);
130
+ console.log(` ${w(`phewsh update`)}`);
131
+ console.log(` ${g('Or reinstall with the installer (handles this for you):')} ${w('curl -fsSL phewsh.com/install.sh | sh')}`);
132
+ console.log(` ${g('Do NOT run `sudo npm i -g` — that is what caused this.')}`);
118
133
  }
119
134
  console.log('');
120
135
  process.exit(code ?? 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phewsh",
3
- "version": "0.15.44",
3
+ "version": "0.15.45",
4
4
  "description": "Turn intent into action. Structure your thinking, execute your next step.",
5
5
  "bin": {
6
6
  "phewsh": "bin/phewsh.js"