User frappe cannot run "/bin/npm install -g yarn" as root.
Traceback (most recent call last):
File "/usr/bin/bench", line 11, in <module>
load_entry_point('bench', 'console_scripts', 'bench')()
File "/home/frappe/.bench/bench/cli.py", line 40, in cli
bench_command()
File "/usr/lib64/python2.7/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/lib64/python2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/lib64/python2.7/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib64/python2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib64/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/frappe/.bench/bench/commands/update.py", line 30, in update
patches.run(bench_path='.')
File "/home/frappe/.bench/bench/patches/__init__.py", line 21, in run
result = execute(bench_path)
File "/home/frappe/.bench/bench/patches/v4/install_yarn.py", line 4, in execute
subprocess.check_output(['sudo', 'npm', 'install', '-g', 'yarn'])
File "/usr/lib64/python2.7/subprocess.py", line 575, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['sudo', 'npm', 'install', '-g', 'yarn']' returned non-zero exit status 1
The patch didn’t seem to have any effect on my system.
I just installed yarn through npm install yarn which returns a warning message
npm WARN deprecated yarn@1.3.2: It is recommended to install Yarn using the native installation method for your environment. See https://yarnpkg.com/en/docs/install
Updating node libraries...
INFO:bench.utils:./node_modules/.bin/yarn install
/bin/sh: ./node_modules/.bin/yarn: No such file or directory
Traceback (most recent call last):
File "/Users/dominik/Dev/frappe-dev/.venv/bin/bench", line 11, in <module>
load_entry_point('bench', 'console_scripts', 'bench')()
File "/Users/dominik/Dev/frappe-dev/bench-repo/bench/cli.py", line 40, in cli
bench_command()
File "/Users/dominik/Dev/frappe-dev/.venv/lib/python2.7/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/dominik/Dev/frappe-dev/.venv/lib/python2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/dominik/Dev/frappe-dev/.venv/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/dominik/Dev/frappe-dev/.venv/lib/python2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/dominik/Dev/frappe-dev/.venv/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/dominik/Dev/frappe-dev/bench-repo/bench/commands/update.py", line 58, in update
_update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, force=force, reset=reset)
File "/Users/dominik/Dev/frappe-dev/bench-repo/bench/commands/update.py", line 75, in _update
update_npm_packages(bench_path=bench_path)
File "/Users/dominik/Dev/frappe-dev/bench-repo/bench/utils.py", line 437, in update_npm_packages
exec_cmd('./node_modules/.bin/yarn install', cwd=app_path)
File "/Users/dominik/Dev/frappe-dev/bench-repo/bench/utils.py", line 142, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: ./node_modules/.bin/yarn install
The command bench update updates bench itself first. If for some reason your bench is not updated, then cd into ~/.bench folder (or wherever your bench is installed) and do a git pull
I can confirm, that bench update works without any errors and without any sudo npm commands etc. on MacOS at 5PM CET. It also worked on our Ubuntu 17.10 server. Thank you for fixing this so fast.