[FIXED] Yarn error on bench update

Hi there,

getting an error on bench update in production (CentOS 7):

$ sudo bench update
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
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
npm ERR! Linux 3.10.0-693.11.6.el7.x86_64
npm ERR! argv "/usr/bin/node" "/bin/npm" "install" "-g" "yarn"
npm ERR! node v6.13.0
npm ERR! npm  v3.10.10
npm ERR! path /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR!     at Error (native)
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/frappe/frappe-bench/npm-debug.log
Traceback (most recent call last):
  File "/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(['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 '['npm', 'install', '-g', 'yarn']' returned non-zero exit status 243

npm-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/bin/npm', 'install', '-g', 'yarn' ]
2 info using npm@3.10.10
3 info using node@v6.13.0
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData yarn
8 silly fetchNamedPackageData yarn
9 silly mapToRegistry name yarn
10 silly mapToRegistry using default registry
11 silly mapToRegistry registry https://registry.npmjs.org/
12 silly mapToRegistry data Result {
12 silly mapToRegistry   raw: 'yarn',
12 silly mapToRegistry   scope: null,
12 silly mapToRegistry   escapedName: 'yarn',
12 silly mapToRegistry   name: 'yarn',
12 silly mapToRegistry   rawSpec: '',
12 silly mapToRegistry   spec: 'latest',
12 silly mapToRegistry   type: 'tag' }
13 silly mapToRegistry uri https://registry.npmjs.org/yarn
14 verbose request uri https://registry.npmjs.org/yarn
15 verbose request no auth needed
16 info attempt registry request try #1 at 08:48:24
17 verbose request id 094dcd5666f1a5ea
18 verbose etag "5a7d7391-33f9b"
19 verbose lastModified Fri, 9 Feb 2018 10:10:25 GMT
20 http request GET https://registry.npmjs.org/yarn
21 http 304 https://registry.npmjs.org/yarn
22 verbose headers { date: 'Mon, 19 Feb 2018 07:48:24 GMT',
22 verbose headers   via: '1.1 varnish',
22 verbose headers   'cache-control': 'max-age=300',
22 verbose headers   etag: '"5a7d7391-33f9b"',
22 verbose headers   age: '6670',
22 verbose headers   connection: 'keep-alive',
22 verbose headers   'x-served-by': 'cache-cdg8720-CDG',
22 verbose headers   'x-cache': 'HIT',
22 verbose headers   'x-cache-hits': '1',
22 verbose headers   'x-timer': 'S1519026504.372168,VS0,VE1',
22 verbose headers   vary: 'Accept-Encoding, Accept' }
23 silly get cb [ 304,
23 silly get   { date: 'Mon, 19 Feb 2018 07:48:24 GMT',
23 silly get     via: '1.1 varnish',
23 silly get     'cache-control': 'max-age=300',
23 silly get     etag: '"5a7d7391-33f9b"',
23 silly get     age: '6670',
23 silly get     connection: 'keep-alive',
23 silly get     'x-served-by': 'cache-cdg8720-CDG',
23 silly get     'x-cache': 'HIT',
23 silly get     'x-cache-hits': '1',
23 silly get     'x-timer': 'S1519026504.372168,VS0,VE1',
23 silly get     vary: 'Accept-Encoding, Accept' } ]
24 verbose etag https://registry.npmjs.org/yarn from cache
25 verbose get saving yarn to /home/frappe/.npm/registry.npmjs.org/yarn/.cache.json
26 verbose correctMkdir /home/frappe/.npm correctMkdir not in flight; initializing
27 silly install normalizeTree
28 silly loadCurrentTree Finishing
29 silly loadIdealTree Starting
30 silly install loadIdealTree
31 silly cloneCurrentTree Starting
32 silly install cloneCurrentTreeToIdealTree
33 silly cloneCurrentTree Finishing
34 silly loadShrinkwrap Starting
35 silly install loadShrinkwrap
36 silly loadShrinkwrap Finishing
37 silly loadAllDepsIntoIdealTree Starting
38 silly install loadAllDepsIntoIdealTree
39 silly resolveWithNewModule yarn@1.3.2 checking installable status
40 silly cache add args [ 'yarn', null ]
41 verbose cache add spec yarn
42 silly cache add parsed spec Result {
42 silly cache add   raw: 'yarn',
42 silly cache add   scope: null,
42 silly cache add   escapedName: 'yarn',
42 silly cache add   name: 'yarn',
42 silly cache add   rawSpec: '',
42 silly cache add   spec: 'latest',
42 silly cache add   type: 'tag' }
43 silly addNamed yarn@latest
44 verbose addNamed "latest" is being treated as a dist-tag for yarn
45 info addNameTag [ 'yarn', 'latest' ]
46 silly mapToRegistry name yarn
47 silly mapToRegistry using default registry
48 silly mapToRegistry registry https://registry.npmjs.org/
49 silly mapToRegistry data Result {
49 silly mapToRegistry   raw: 'yarn',
49 silly mapToRegistry   scope: null,
49 silly mapToRegistry   escapedName: 'yarn',
49 silly mapToRegistry   name: 'yarn',
49 silly mapToRegistry   rawSpec: '',
49 silly mapToRegistry   spec: 'latest',
49 silly mapToRegistry   type: 'tag' }
50 silly mapToRegistry uri https://registry.npmjs.org/yarn
51 verbose addNameTag registry:https://registry.npmjs.org/yarn not in flight; fetching
52 verbose get https://registry.npmjs.org/yarn not expired, no request
53 silly addNameTag next cb for yarn with tag latest
54 silly addNamed yarn@1.3.2
55 verbose addNamed "1.3.2" is a plain semver version for yarn
56 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
57 silly cache afterAdd yarn@1.3.2
58 verbose afterAdd /home/frappe/.npm/yarn/1.3.2/package/package.json not in flight; writing
59 verbose correctMkdir /home/frappe/.npm correctMkdir not in flight; initializing
60 verbose afterAdd /home/frappe/.npm/yarn/1.3.2/package/package.json written
61 silly loadAllDepsIntoIdealTree Finishing
62 silly loadIdealTree Finishing
63 silly currentTree lib
64 silly idealTree lib
64 silly idealTree └── yarn@1.3.2
65 silly generateActionsToTake Starting
66 silly install generateActionsToTake
67 warn checkPermissions Missing write access to /usr/lib/node_modules
68 silly rollbackFailedOptional Starting
69 silly rollbackFailedOptional Finishing
70 silly runTopLevelLifecycles Finishing
71 silly install printInstalled
72 verbose stack Error: EACCES: permission denied, access '/usr/lib/node_modules'
72 verbose stack     at Error (native)
73 verbose cwd /home/frappe/frappe-bench
74 error Linux 3.10.0-693.11.6.el7.x86_64
75 error argv "/usr/bin/node" "/bin/npm" "install" "-g" "yarn"
76 error node v6.13.0
77 error npm  v3.10.10
78 error path /usr/lib/node_modules
79 error code EACCES
80 error errno -13
81 error syscall access
82 error Error: EACCES: permission denied, access '/usr/lib/node_modules'
82 error     at Error (native)
82 error  { Error: EACCES: permission denied, access '/usr/lib/node_modules'
82 error     at Error (native)
82 error   errno: -13,
82 error   code: 'EACCES',
82 error   syscall: 'access',
82 error   path: '/usr/lib/node_modules' }
83 error Please try running this command again as root/Administrator.
84 verbose exit [ -13, true ]

Needs sudo npm install yarn?

So it seems we can’t install in global without sudo. Just pushed a fix. Please update and try again.

@netchampfaris still not working:

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
1 Like

Same here on Debian 8.1.

I had to go to bench-repo directory and do a

git pull

After this, the bench update works again.

Cheers,
–thomas

have you updated bench ?

Same issue here. Cannot update. git pull did not help.

Pushed a fix. Please try again.

Yes, updated

Oh ok …I will try and get back

Same here on MacOS
Time: CET 13:28

bench update –> bench.utils.CommandFailedError: ./node_modules/.bin/yarn install

last fix is working for me on CentOS7 …thx

1 Like

error still there when running bench update. is there something i need to run before bench update? using ubuntu 14

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

After that bench update works.

Now If I run bench update again I get an error:

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

Hi all,

same here on Debian 9. It can be resolved with

$ sudo chown -R frappe:frappe /usr/lib/node_modules

With that, the new yarn works like a charm.

Note: yarn.lock should be added to the .gitignore file.

2 Likes

Hi,

I tried running bench update again, but am again getting the same error:

subprocess.CalledProcessError: Command ‘[‘sudo’, ‘npm’, ‘install’, ‘-g’, ‘yarn’]’ returned non-zero exit status 1

I pushed a fix. Please update your bench.

how im going to update my bench if the problem is "bench update doens’t work "

1 Like

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

4 Likes

Following command fixed my issue on new ubuntu 16.04

sudo npm install -g yarn
bench update --requirements
bench setup socketio
bench build
2 Likes