rails/sass-rails

[ARM64] Creating Rails 6.1.5 app in JRuby 9.3.3.0 fails due to sass-rails relying on C library

AndyObtiva opened this issue · 2 comments

I tried creating a new rails 6.1.5 app under jruby-9.3.3.0 (using rails new app_name), and I got an error during installation of gems (sass-rails gem):

Installing sassc 2.4.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/andymaleh/.rvm/gems/jruby-9.3.3.0@code/gems/sassc-2.4.0/ext
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/bin/jruby -I
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/stdlib -r
./siteconf20220429-45551-13rk1ls.rb extconf.rb
creating Makefile

current directory:
/Users/andymaleh/.rvm/gems/jruby-9.3.3.0@code/gems/sassc-2.4.0/ext
make DESTDIR\= clean

current directory:
/Users/andymaleh/.rvm/gems/jruby-9.3.3.0@code/gems/sassc-2.4.0/ext
make DESTDIR\=
compiling ./libsass/src/ast.cpp
clang: error: invalid arch name '-arch aarch64'
make: *** [ast.o] Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/andymaleh/.rvm/gems/jruby-9.3.3.0@code/gems/sassc-2.4.0 for inspection.
Results logged to
/Users/andymaleh/.rvm/gems/jruby-9.3.3.0@code/extensions/universal-java-17/2.6.0/sassc-2.4.0/gem_make.out

/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/stdlib/rubygems/ext/builder.rb:92:in
`run'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/stdlib/rubygems/ext/builder.rb:43:in
`block in make'
  org/jruby/RubyArray.java:1865:in `each'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/stdlib/rubygems/ext/builder.rb:35:in
`make'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:63:in
`block in build'
  org/jruby/ext/tempfile/Tempfile.java:242:in `open'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:26:in
`build'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/stdlib/rubygems/ext/builder.rb:158:in
`build_extension'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/stdlib/rubygems/ext/builder.rb:192:in
`block in build_extensions'
  org/jruby/RubyArray.java:1865:in `each'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/stdlib/rubygems/ext/builder.rb:189:in
`build_extensions'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/stdlib/rubygems/installer.rb:837:in
`build_extensions'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/gems/shared/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:71:in
`build_extensions'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/gems/shared/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:28:in
`install'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/gems/shared/gems/bundler-2.3.5/lib/bundler/source/rubygems.rb:204:in
`install'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/gems/shared/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:54:in
`install'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/gems/shared/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/gems/shared/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:186:in
`do_install'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/gems/shared/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:177:in
`block in worker_pool'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/gems/shared/gems/bundler-2.3.5/lib/bundler/worker.rb:62:in
`apply_func'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/gems/shared/gems/bundler-2.3.5/lib/bundler/worker.rb:57:in
`block in process_queue'
  org/jruby/RubyKernel.java:1507:in `loop'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/gems/shared/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in
`process_queue'
/Users/andymaleh/.rvm/rubies/jruby-9.3.3.0/lib/ruby/gems/shared/gems/bundler-2.3.5/lib/bundler/worker.rb:91:in
`block in create_threads'

An error occurred while installing sassc (2.4.0), and Bundler cannot
continue.

In Gemfile:
  sass-rails was resolved to 6.0.0, which depends on
    sassc-rails was resolved to 2.1.2, which depends on
      sassc

It seems that the issue is that sass-rails hardcodes a C dependency for a gem that is usable in JRuby too.

% uname -a
Darwin Andys-Lexop-MacBook-Pro.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:47:26 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T8101 arm64

CC @headius and @enebo

I believe this may be fixed under JRuby 9.3.4.0, which fixed some build flags related to arm64 and Mac OS's atypical arch flag (arm64 instead of aarch64).

I confirm that this works in JRuby 9.3.4.0. Closing...