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

Test updating node 16 #34308

Closed

Conversation

brian-smith-tcril
Copy link
Contributor

@brian-smith-tcril brian-smith-tcril commented Feb 28, 2024

When running

nvm use 16
npm ci

on latest master (1339313 as of writing) I encountered a few problems.

I found the simplest solution was to just use node 16.14 (see #34307), but I wanted to dig into why the latest version of node 16 wasn't working.

The first error I encountered was

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/selenium-webdriver
npm ERR!   dev selenium-webdriver@"3.4.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer selenium-webdriver@"^2.44.0" from [email protected]
npm ERR! node_modules/karma-selenium-webdriver-launcher
npm ERR!   dev karma-selenium-webdriver-launcher@"0.0.4" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/selenium-webdriver
npm ERR!   peer selenium-webdriver@"^2.44.0" from [email protected]
npm ERR!   node_modules/karma-selenium-webdriver-launcher
npm ERR!     dev karma-selenium-webdriver-launcher@"0.0.4" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /home/bsmith/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/bsmith/.npm/_logs/2024-02-28T20_37_31_843Z-debug-0.log

This was because of the karma-selenium-webdriver-launcher package. We are already using the newest version of this package, but that version is 7 years old. That package has "selenium-webdriver": "^2.44.0" listed in peerDependencies.

I forked the package and made a branch updating the peer dependency to use "selenium-webdriver": ">=2.44.0"

I then updated the package.json to use my forked version
https://github.com/openedx/edx-platform/blob/5ff405e86133a922d080b2819e348a12827b0223/package.json#L108

and ran npm install.

At this point I encountered a new error

npm ERR! /home/bsmith/.node-gyp/16.20.2/include/node/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
npm ERR!   492 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!       |                                      ^~~~~~~~~~~
npm ERR!       |                                      remove_cv
npm ERR! /home/bsmith/.node-gyp/16.20.2/include/node/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
npm ERR!   492 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!       |                                      ^~~~~~~~~~~
npm ERR!       |                                      remove_cv
npm ERR! /home/bsmith/.node-gyp/16.20.2/include/node/v8-internal.h:492:50: error: template argument 2 is invalid
npm ERR!   492 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!       |                                                  ^
npm ERR! /home/bsmith/.node-gyp/16.20.2/include/node/v8-internal.h:492:63: error: ‘::Perform’ has not been declared
npm ERR!   492 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!       |                                                               ^~~~~~~
npm ERR! ../src/binding.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE render(Nan::NAN_METHOD_ARGS_TYPE)’:
npm ERR! ../src/binding.cpp:284:80: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
npm ERR!   284 |     int status = uv_queue_work(uv_default_loop(), &ctx_w->request, compile_it, (uv_after_work_cb)MakeCallback);
npm ERR!       |                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ../src/binding.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE render_file(Nan::NAN_METHOD_ARGS_TYPE)’:
npm ERR! ../src/binding.cpp:320:80: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
npm ERR!   320 |     int status = uv_queue_work(uv_default_loop(), &ctx_w->request, compile_it, (uv_after_work_cb)MakeCallback);
npm ERR!       |                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ../src/binding.cpp: At global scope:
npm ERR! /home/bsmith/.node-gyp/16.20.2/include/node/node.h:887:7: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
npm ERR!   887 |       (node::addon_register_func) (regfunc),                          \
npm ERR!       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /home/bsmith/.node-gyp/16.20.2/include/node/node.h:921:3: note: in expansion of macro ‘NODE_MODULE_X’
npm ERR!   921 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
npm ERR!       |   ^~~~~~~~~~~~~
npm ERR! ../src/binding.cpp:358:1: note: in expansion of macro ‘NODE_MODULE’
npm ERR!   358 | NODE_MODULE(binding, RegisterModule);
npm ERR!       | ^~~~~~~~~~~
npm ERR! make: *** [binding.target.mk:133: Release/obj.target/binding/src/binding.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2

which led me to https://stackoverflow.com/a/70086482

Same issue, this fixes it for me:

CXXFLAGS="--std=c++17" yarn install

node-sass specifies -std=c++0x in the version we have installed (version 4) https://github.com/sass/node-sass/blob/v4.14.1/src/libsass.gyp#L106-L110, but also in latest master https://github.com/sass/node-sass/blob/6081731aac89ce4612fe4839d4c6329539c0d8e1/src/libsass.gyp#L106-L110, and remove_cv_t was added in C++ 14 https://en.cppreference.com/w/cpp/types/remove_cv

template< class T >
using remove_cv_t = typename remove_cv::type;
(since C++14)

I tried using C++ 20 but encountered some C++ 20 specific errors, so I went back to 17.

C++ 20 Errors
npm ERR! ../src/libsass/src/ast.cpp:445:94: error: ambiguous overload for ‘operator==’ (operand types are ‘const Sass::Selector_List’ and ‘const Sass::Compound_Selector’)
npm ERR!   445 |     else if (Compound_Selector_Ptr_Const cpd = Cast<Compound_Selector>(&rhs)) { return *this == *cpd; }
npm ERR!       |                                                                                        ~~~~~ ^~ ~~~~
npm ERR!       |                                                                                        |        |
npm ERR!       |                                                                                        |        const Sass::Compound_Selector
npm ERR!       |                                                                                        const Sass::Selector_List
npm ERR! ../src/libsass/src/ast.cpp:368:8: note: candidate: ‘virtual bool Sass::Compound_Selector::operator==(const Sass::Selector&) const’ (reversed)
npm ERR!   368 |   bool Compound_Selector::operator== (const Selector& rhs) const
npm ERR!       |        ^~~~~~~~~~~~~~~~~
npm ERR! ../src/libsass/src/ast.cpp:440:8: note: candidate: ‘virtual bool Sass::Selector_List::operator==(const Sass::Selector&) const’
npm ERR!   440 |   bool Selector_List::operator== (const Selector& rhs) const
npm ERR!       |        ^~~~~~~~~~~~~
npm ERR! ../src/libsass/src/ast.hpp:3030:18: note: candidate: ‘virtual bool Sass::Selector_List::operator==(const Sass::Expression&) const’
npm ERR!  3030 |     virtual bool operator==(const Expression& rhs) const;
npm ERR!       |                  ^~~~~~~~
npm ERR! ../src/libsass/src/ast.cpp: In member function ‘virtual bool Sass::Selector_List::operator==(const Sass::Expression&) const’:
npm ERR! ../src/libsass/src/ast.cpp:454:60: error: ambiguous overload for ‘operator==’ (operand types are ‘const Sass::List’ and ‘const Sass::Selector_List’)
npm ERR!   454 |     if (List_Ptr_Const ls = Cast<List>(&rhs)) { return *ls == *this; }
npm ERR!       |                                                        ~~~ ^~ ~~~~~
npm ERR!       |                                                        |      |
npm ERR!       |                                                        |      const Sass::Selector_List
npm ERR!       |                                                        const Sass::List
npm ERR! ../src/libsass/src/ast.cpp:451:8: note: candidate: ‘virtual bool Sass::Selector_List::operator==(const Sass::Expression&) const’ (reversed)
npm ERR!   451 |   bool Selector_List::operator== (const Expression& rhs) const
npm ERR!       |        ^~~~~~~~~~~~~
npm ERR! ../src/libsass/src/ast.hpp:1124:18: note: candidate: ‘virtual bool Sass::List::operator==(const Sass::Expression&) const’
npm ERR!  1124 |     virtual bool operator== (const Expression& rhs) const;
npm ERR!       |                  ^~~~~~~~
npm ERR! ../src/libsass/src/ast.cpp: In member function ‘virtual bool Sass::Attribute_Selector::operator==(const Sass::Attribute_Selector&) const’:
npm ERR! ../src/libsass/src/ast.cpp:694:36: warning: C++20 says that these are ambiguous, even though the second is reversed:
npm ERR!   694 |         && (*value() == *rhs.value());

I then ran

CXXFLAGS="--std=c++17" npm install
rm -rf node_modules
CXXFLAGS="--std=c++17" npm ci

and everything worked.

I've updated the Dockerfile and the js-tests.yml workflow to use 16.20, and added the CXXFLAGS to the npm ci lines in the Dockerfile and pavelib/prereqs.py.

@brian-smith-tcril brian-smith-tcril force-pushed the test-update-node-16 branch 3 times, most recently from 71901c9 to 95c65a0 Compare February 28, 2024 21:33
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 this pull request may close these issues.

1 participant