inveniosoftware / troubleshooting

DEPRECATED - Use the forum instead:
https://invenio-talk.web.cern.ch
5 stars 4 forks source link

scripts/bootstrap issue #38

Closed AlexaLogush closed 5 years ago

AlexaLogush commented 6 years ago

The Bootstrap Scripts stopped without error at npm install and didn't run the invenio collect -v and invenio assets build. We were following these directions. When we tried running the invenio assets build manually we get the following error:

Building bundle: gen/search.%(version)s.js Failed, error was: Program file not found: r.js. Building bundle: gen/styles.%(version)s.css Traceback (most recent call last): File "/home/REDACTED/.virtualenvs/archive/bin/invenio", line 11, in sys.exit(cli()) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/click/core.py", line 722, in call return self.main(*args, kwargs) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/flask/cli.py", line 557, in main return super(FlaskGroup, self).main(args, kwargs) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke return callback(args, kwargs) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, kwargs) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/flask/cli.py", line 412, in decorator return __ctx.invoke(f, *args, *kwargs) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke return callback(args, kwargs) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/flask_assets.py", line 492, in build _webassets_cmd('build') File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/flask_assets.py", line 480, in _webassets_cmd getattr(cmdenv, cmd)() File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/webassets/script.py", line 172, in call bundle.build(force=True, disable_cache=no_cache) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/webassets/bundle.py", line 682, in build disable_cache=disable_cache)) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/webassets/bundle.py", line 619, in _build force, disable_cache=disable_cache, extra_filters=extra_filters) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/webassets/bundle.py", line 543, in _merge_and_apply kwargs=item_data) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/webassets/merge.py", line 276, in apply return self._wrap_cache(key, func) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/webassets/merge.py", line 218, in _wrap_cache content = func().getvalue() File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/webassets/merge.py", line 251, in func getattr(filter, type)(data, out, **kwargs_final) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/webassets/filter/sass.py", line 196, in input self._apply_sass(_in, out, os.path.dirname(source_path)) File "/home/REDACTED/.virtualenvs/archive/local/lib/python2.7/site-packages/webassets/filter/node_sass.py", line 80, in _apply_sass shell=(os.name == 'nt')) File "/usr/lib64/python2.7/subprocess.py", line 390, in init errread, errwrite) File "/usr/lib64/python2.7/subprocess.py", line 1025, in _execute_child raise child_exception OSError: [Errno 13] Permission denied

lnielsen commented 6 years ago

The error looks like the NPM tools have not been installed. You should have the 4 following programs available in the PATH:

$ which r.js
/usr/local/bin/r.js
$ which node-sass
/usr/local/bin/node-sass
$ which cleancss
/usr/local/bin/cleancss
$ which uglifyjs
/usr/local/bin/uglifyjs

It is this line installing them in the boostrap-script: npm update && npm install --silent -g node-sass@4.9.0 clean-css@3.4.19 uglify-js@2.7.3 requirejs@2.2.0

foureyes commented 6 years ago

Thanks! In some environments, installing npm modules globally requires sudo by default (for example, Ubuntu 18.04). Consequently, combined with the --silent flag, this command fails without complaint (worst yet, npm still shows output - just not errors - so it looks like the installation succeeds!).

For these environments, users will have to run this command manually:

sudo npm install -g node-sass@4.9.0 clean-css@3.4.19 uglify-js@2.7.3 
lnielsen commented 6 years ago

👍 I've reported it as an error on the cookiecutter template.

foureyes commented 6 years ago

My previous comment regarding sudo only works for 2 of the 3 packages. Based on some info from node-sass 1098, you may have install node-sass as root, use a flag to allow unsafe-perms, use nvm, or modify node_modules so that installing modules globally doesn't require super user permissions (for example, some distributions of linux).

Additionally, I had to manually install requirejs manually.

The resulting line for npm installation (if you don't care about npm install scripts switching to root) is:

sudo npm install -g --unsafe-perm node-sass@4.9.0 clean-css@3.4.19 uglify-js@2.7.3 requirejs

(Check this issue for more info on using unsafe-perm).

AFAIK, these issues definitely affect:

iGormilhit commented 6 years ago

At RERO we install the node package into the python virtual environment, in order to avoid installing things into the OS itself.

We do it with --prefix $VIRTUAL_ENV added to npm commands.