[root@localhost ~ ]# gem install sassc Building native extensions. This could take a while... ERROR: Error installing sassc: ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1/ext /usr/local/rvm/rubies/ruby-2.6.2/bin/ruby -rrubygems /usr/local/rvm/rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems/rake-12.3.2/exe/rake RUBYARCHDIR\=/usr/local/rvm/gems/ruby-2.6.2/extensions/x86_64-linux/2.6.0/sassc-2.0.1 RUBYLIBDIR\=/usr/local/rvm/gems/ruby-2.6.2/extensions/x86_64-linux/2.6.0/sassc-2.0.1 cd libsass make lib/libsass.so mkdir lib cc -Wall -O2 -I /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1/ext/libsass/include -fPIC -fPIC -c -o src/cencode.o src/cencode.c src/cencode.c: In function ‘base64_encode_block’: src/cencode.c:50: warning: empty declaration src/cencode.c:64: warning: empty declaration g++ -Wall -O2 -std=c++0x -I /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1/ext/libsass/include -fPIC -fPIC -c -o src/ast.o src/ast.cpp In file included from src/ast.cpp:2: src/ast.hpp: In member function ‘virtual size_t Sass::Vectorized<T>::hash()’: src/ast.hpp:336: error: expected initializer before ‘:’ token src/ast.hpp:339: error: expected primary-expression before ‘}’ token src/ast.hpp:339: error: expected ‘;’ before ‘}’ token src/ast.hpp:339: error: expected primary-expression before ‘}’ token src/ast.hpp:339: error: expected ‘)’ before ‘}’ token src/ast.hpp:339: error: expected primary-expression before ‘}’ token src/ast.hpp:339: error: expected ‘;’ before ‘}’ token src/ast.hpp: In constructor ‘Sass::Hashed::Hashed(size_t)’: src/ast.hpp:373: error: ‘class Sass::ExpressionMap’ has no member named ‘reserve’ src/ast.hpp: In member function ‘Sass::Hashed& Sass::Hashed::operator+=(Sass::Hashed*)’: src/ast.hpp:402: error: expected initializer before ‘:’ token src/ast.hpp:406: error: could not convert ‘Sass::Hashed::reset_duplicate_key()’ to ‘bool’ src/ast.hpp:407: error: expected primary-expression before ‘return’ src/ast.hpp:407: error: expected ‘)’ before ‘return’ In file included from src/ast.cpp:2: src/ast.hpp: In member function ‘virtual size_t Sass::Map::hash()’: src/ast.hpp:1153: error: expected initializer before ‘:’ token src/ast.hpp:1157: error: expected primary-expression before ‘}’ token src/ast.hpp:1157: error: expected ‘;’ before ‘}’ token src/ast.hpp:1157: error: expected primary-expression before ‘}’ token src/ast.hpp:1157: error: expected ‘)’ before ‘}’ token src/ast.hpp:1157: error: expected primary-expression before ‘}’ token src/ast.hpp:1157: error: expected ‘;’ before ‘}’ token src/ast.hpp: In member function ‘virtual size_t Sass::Function_Call::hash()’: src/ast.hpp:1522: error: expected initializer before ‘:’ token src/ast.hpp:1524: error: expected primary-expression before ‘}’ token src/ast.hpp:1524: error: expected ‘;’ before ‘}’ token src/ast.hpp:1524: error: expected primary-expression before ‘}’ token src/ast.hpp:1524: error: expected ‘)’ before ‘}’ token src/ast.hpp:1524: error: expected primary-expression before ‘}’ token src/ast.hpp:1524: error: expected ‘;’ before ‘}’ token src/ast.hpp: In member function ‘virtual size_t Sass::Number::hash()’: src/ast.hpp:1614: error: expected initializer before ‘:’ token src/ast.hpp:1616: error: expected primary-expression before ‘for’ src/ast.hpp:1616: error: expected ‘;’ before ‘for’ src/ast.hpp:1616: error: expected primary-expression before ‘for’ src/ast.hpp:1616: error: expected ‘)’ before ‘for’ src/ast.hpp:1616: error: expected initializer before ‘:’ token src/ast.hpp:1618: error: expected primary-expression before ‘}’ token src/ast.hpp:1618: error: expected ‘;’ before ‘}’ token src/ast.hpp:1618: error: expected primary-expression before ‘}’ token src/ast.hpp:1618: error: expected ‘)’ before ‘}’ token src/ast.hpp:1618: error: expected primary-expression before ‘}’ token src/ast.hpp:1618: error: expected ‘;’ before ‘}’ token src/ast.hpp: In member function ‘bool Sass::String_Schema::has_interpolants()’: src/ast.hpp:1791: error: expected initializer before ‘:’ token src/ast.hpp:1794: error: expected primary-expression before ‘return’ src/ast.hpp:1794: error: expected ‘;’ before ‘return’ src/ast.hpp:1794: error: expected primary-expression before ‘return’ src/ast.hpp:1794: error: expected ‘)’ before ‘return’ src/ast.hpp: In member function ‘virtual size_t Sass::String_Schema::hash()’: src/ast.hpp:1801: error: expected initializer before ‘:’ token src/ast.hpp:1803: error: expected primary-expression before ‘}’ token src/ast.hpp:1803: error: expected ‘;’ before ‘}’ token src/ast.hpp:1803: error: expected primary-expression before ‘}’ token src/ast.hpp:1803: error: expected ‘)’ before ‘}’ token src/ast.hpp:1803: error: expected primary-expression before ‘}’ token src/ast.hpp:1803: error: expected ‘;’ before ‘}’ token src/ast.hpp: In member function ‘virtual size_t Sass::Compound_Selector::hash()’: src/ast.hpp:2750: error: ‘template<class T> class Sass::Vectorized’ used without template parameters src/ast.hpp: In member function ‘virtual size_t Sass::Selector_List::hash()’: src/ast.hpp:2997: error: ‘template<class T> class Sass::Vectorized’ used without template parameters src/ast.hpp: In member function ‘virtual void Sass::Selector_List::set_media_block(Sass::Media_Block*)’: src/ast.hpp:3014: error: expected initializer before ‘:’ token src/ast.hpp:3017: error: expected primary-expression before ‘}’ token src/ast.hpp:3017: error: expected ‘;’ before ‘}’ token src/ast.hpp:3017: error: expected primary-expression before ‘}’ token src/ast.hpp:3017: error: expected ‘)’ before ‘}’ token src/ast.hpp:3017: error: expected primary-expression before ‘}’ token src/ast.hpp:3017: error: expected ‘;’ before ‘}’ token src/ast.hpp: In member function ‘virtual bool Sass::Selector_List::has_placeholder()’: src/ast.hpp:3019: error: expected initializer before ‘:’ token src/ast.hpp:3022: error: expected primary-expression before ‘return’ src/ast.hpp:3022: error: expected ‘;’ before ‘return’ src/ast.hpp:3022: error: expected primary-expression before ‘return’ src/ast.hpp:3022: error: expected ‘)’ before ‘return’ src/ast.cpp: In member function ‘virtual bool Sass::Selector_List::find(bool (*)(Sass::AST_Node_Obj))’: src/ast.cpp:35: error: expected initializer before ‘:’ token src/ast.cpp:39: error: expected primary-expression before ‘return’ src/ast.cpp:39: error: expected ‘;’ before ‘return’ src/ast.cpp:39: error: expected primary-expression before ‘return’ src/ast.cpp:39: error: expected ‘)’ before ‘return’ src/ast.cpp: In member function ‘virtual bool Sass::Compound_Selector::find(bool (*)(Sass::AST_Node_Obj))’: src/ast.cpp:45: error: expected initializer before ‘:’ token src/ast.cpp:49: error: expected primary-expression before ‘return’ src/ast.cpp:49: error: expected ‘;’ before ‘return’ src/ast.cpp:49: error: expected primary-expression before ‘return’ src/ast.cpp:49: error: expected ‘)’ before ‘return’ src/ast.cpp: In member function ‘virtual void Sass::Arguments::set_delayed(bool)’: src/ast.cpp:98: error: expected initializer before ‘:’ token src/ast.cpp:102: error: expected primary-expression before ‘}’ token src/ast.cpp:102: error: expected ‘)’ before ‘}’ token src/ast.cpp:102: error: expected primary-expression before ‘}’ token src/ast.cpp:102: error: expected ‘;’ before ‘}’ token src/ast.cpp: In member function ‘virtual bool Sass::Compound_Selector::has_parent_ref() const’: src/ast.cpp:171: error: expected initializer before ‘:’ token src/ast.cpp:174: error: expected primary-expression before ‘return’ src/ast.cpp:174: error: expected ‘;’ before ‘return’ src/ast.cpp:174: error: expected primary-expression before ‘return’ src/ast.cpp:174: error: expected ‘)’ before ‘return’ src/ast.cpp: In member function ‘virtual bool Sass::Compound_Selector::has_real_parent_ref() const’: src/ast.cpp:179: error: expected initializer before ‘:’ token src/ast.cpp:182: error: expected primary-expression before ‘return’ src/ast.cpp:182: error: expected ‘;’ before ‘return’ src/ast.cpp:182: error: expected primary-expression before ‘return’ src/ast.cpp:182: error: expected ‘)’ before ‘return’ src/ast.cpp: In member function ‘virtual bool Sass::Compound_Selector::is_superselector_of(Sass::Selector_List_Obj, std::string)’: src/ast.cpp:846: error: expected initializer before ‘:’ token src/ast.cpp:849: error: expected primary-expression before ‘return’ src/ast.cpp:849: error: expected ‘;’ before ‘return’ src/ast.cpp:849: error: expected primary-expression before ‘return’ src/ast.cpp:849: error: expected ‘)’ before ‘return’ src/ast.cpp: In member function ‘Sass::Selector_List* Sass::Complex_Selector::resolve_parent_refs(std::vector<Sass::SharedImpl<Sass::Selector_List>, std::allocator<Sass::SharedImpl<Sass::Selector_List> > >&, Sass::Backtraces&, bool)’: src/ast.cpp:1408: error: expected initializer before ‘:’ token src/ast.cpp:2226: error: expected primary-expression at end of input src/ast.cpp:2226: error: expected ‘;’ at end of input src/ast.cpp:2226: error: expected primary-expression at end of input src/ast.cpp:2226: error: expected ‘)’ at end of input src/ast.cpp:2226: error: expected statement at end of input src/ast.cpp:2226: error: expected ‘}’ at end of input src/ast.cpp:2226: error: expected ‘}’ at end of input src/ast.cpp: At global scope: src/ast.cpp:2226: error: expected ‘}’ at end of input src/units.hpp:11: warning: ‘Sass::PI’ defined but not used make: *** [src/ast.o] Error 1 rake aborted! Command failed with status (2): [make lib/libsass.so...] /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1/lib/tasks/libsass.rb:31:in `block (2 levels) in <top (required)>' /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1/lib/tasks/libsass.rb:13:in `block (3 levels) in <top (required)>' /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1/lib/tasks/libsass.rb:12:in `block (2 levels) in <top (required)>' Tasks: TOP => lib/libsass.so (See full trace by running task with --trace)
rake failed, exit code 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1 for inspection. Results logged to /usr/local/rvm/gems/ruby-2.6.2/extensions/x86_64-linux/2.6.0/sassc-2.0.1/gem_make.out
经排查,是因为GCC的版本过低导致的。
按照这个步骤,检查下GCC版本,如果是同样的版本和报错,那么可以参考以下的解决方法:
1 2
[root@localhost ~]# gcc --version | head -n1 gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)