Skip to content

rails tailwindcss:build fails on Apple M1. #121

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

Closed
andrewculver opened this issue Jan 4, 2022 · 11 comments
Closed

rails tailwindcss:build fails on Apple M1. #121

andrewculver opened this issue Jan 4, 2022 · 11 comments

Comments

@andrewculver
Copy link
Contributor

andrewculver commented Jan 4, 2022

I'm able to reproduce this with just rails new example-application --css=tailwind.

Example output:

andrewculver@Andrews-MacBook-Pro Sites % rails new example-application --css=tailwind
      create  
      create  README.md
      create  Rakefile
      create  .ruby-version
      create  config.ru
      create  .gitignore
      create  .gitattributes
      create  Gemfile
         run  git init from "."
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint: 	git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint: 	git branch -m <name>
Initialized empty Git repository in /Users/andrewculver/Sites/example-application/.git/
      create  app
      create  app/assets/config/manifest.js
      create  app/assets/stylesheets/application.css
      create  app/channels/application_cable/channel.rb
      create  app/channels/application_cable/connection.rb
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/jobs/application_job.rb
      create  app/mailers/application_mailer.rb
      create  app/models/application_record.rb
      create  app/views/layouts/application.html.erb
      create  app/views/layouts/mailer.html.erb
      create  app/views/layouts/mailer.text.erb
      create  app/assets/images
      create  app/assets/images/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/rails
      create  bin/rake
      create  bin/setup
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/cable.yml
      create  config/puma.rb
      create  config/storage.yml
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/assets.rb
      create  config/initializers/content_security_policy.rb
      create  config/initializers/cors.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/new_framework_defaults_7_0.rb
      create  config/initializers/permissions_policy.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/master.key
      append  .gitignore
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/apple-touch-icon-precomposed.png
      create  public/apple-touch-icon.png
      create  public/favicon.ico
      create  public/robots.txt
      create  tmp
      create  tmp/.keep
      create  tmp/pids
      create  tmp/pids/.keep
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor
      create  vendor/.keep
      create  test/fixtures/files
      create  test/fixtures/files/.keep
      create  test/controllers
      create  test/controllers/.keep
      create  test/mailers
      create  test/mailers/.keep
      create  test/models
      create  test/models/.keep
      create  test/helpers
      create  test/helpers/.keep
      create  test/integration
      create  test/integration/.keep
      create  test/channels/application_cable/connection_test.rb
      create  test/test_helper.rb
      create  test/system
      create  test/system/.keep
      create  test/application_system_test_case.rb
      create  storage
      create  storage/.keep
      create  tmp/storage
      create  tmp/storage/.keep
      remove  config/initializers/cors.rb
      remove  config/initializers/new_framework_defaults_7_0.rb
         run  bundle install
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Using rake 13.0.6
Using concurrent-ruby 1.1.9
Using marcel 1.0.2
Using builder 3.2.4
Using erubi 1.10.0
Using bindex 0.8.1
Using msgpack 1.4.2
Using bundler 2.3.4
Using matrix 0.4.2
Using mini_portile2 2.6.1
Using childprocess 4.1.0
Using io-console 0.5.11
Using method_source 1.0.0
Using public_suffix 4.0.6
Using zeitwerk 2.5.3
Using rexml 3.2.5
Using rubyzip 2.3.2
Using sqlite3 1.4.2
Using i18n 1.8.11
Using tzinfo 2.0.4
Using bootsnap 1.9.3
Using minitest 5.15.0
Using mini_mime 1.1.2
Using selenium-webdriver 4.1.0
Using nio4r 2.5.8
Using activesupport 7.0.0
Using websocket-extensions 0.1.5
Using rack 2.2.3
Using mail 2.7.1
Using reline 0.3.1
Using websocket-driver 0.7.5
Using sprockets 4.0.2
Using regexp_parser 2.2.0
Using irb 1.4.1
Using rack-test 1.1.0
Using addressable 2.8.0
Using globalid 1.0.0
Using activemodel 7.0.0
Using crass 1.0.6
Using thor 1.1.0
Using racc 1.6.0
Using puma 5.5.2
Using activerecord 7.0.0
Using activejob 7.0.0
Using debug 1.4.0
Using nokogiri 1.12.5
Using xpath 3.2.0
Using webdrivers 5.0.0
Using capybara 3.36.0
Using rails-dom-testing 2.0.3
Using loofah 2.13.0
Using rails-html-sanitizer 1.4.2
Using actionview 7.0.0
Using actionpack 7.0.0
Using jbuilder 2.11.5
Using activestorage 7.0.0
Using actionmailer 7.0.0
Using railties 7.0.0
Using sprockets-rails 3.4.2
Using actioncable 7.0.0
Using actiontext 7.0.0
Using stimulus-rails 1.0.2
Using turbo-rails 1.0.0
Using web-console 4.2.0
Using actionmailbox 7.0.0
Using importmap-rails 1.0.1
Using tailwindcss-rails 2.0.3
Using rails 7.0.0
Bundle complete! 16 Gemfile dependencies, 68 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
         run  bundle binstubs bundler
       rails  importmap:install
Add Importmap include tags in application layout
      insert  app/views/layouts/application.html.erb
Create application.js module as entrypoint
      create  app/javascript/application.js
Use vendor/javascript for downloaded pins
      create  vendor/javascript
      create  vendor/javascript/.keep
Ensure JavaScript files are in the Sprocket manifest
      append  app/assets/config/manifest.js
Configure importmap paths in config/importmap.rb
      create  config/importmap.rb
Copying binstub
      create  bin/importmap
       rails  turbo:install stimulus:install
Import Turbo
      append  app/javascript/application.js
Pin Turbo
      append  config/importmap.rb
Enable redis in bundle
        gsub  Gemfile
         run  bundle install
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using rake 13.0.6
Using concurrent-ruby 1.1.9
Using minitest 5.15.0
Using builder 3.2.4
Using mini_portile2 2.6.1
Using crass 1.0.6
Using msgpack 1.4.2
Using bindex 0.8.1
Using bundler 2.3.4
Using marcel 1.0.2
Using mini_mime 1.1.2
Using matrix 0.4.2
Using io-console 0.5.11
Using method_source 1.0.0
Using rack 2.2.3
Using public_suffix 4.0.6
Using zeitwerk 2.5.3
Using rubyzip 2.3.2
Using regexp_parser 2.2.0
Using i18n 1.8.11
Using tzinfo 2.0.4
Using erubi 1.10.0
Using rack-test 1.1.0
Using racc 1.6.0
Using thor 1.1.0
Using sprockets 4.0.2
Using nio4r 2.5.8
Using activesupport 7.0.0
Using addressable 2.8.0
Using sqlite3 1.4.2
Using redis 4.5.1
Using nokogiri 1.12.5
Using activemodel 7.0.0
Using puma 5.5.2
Using childprocess 4.1.0
Using mail 2.7.1
Using globalid 1.0.0
Using rails-dom-testing 2.0.3
Using loofah 2.13.0
Using activerecord 7.0.0
Using reline 0.3.1
Using rexml 3.2.5
Using bootsnap 1.9.3
Using websocket-extensions 0.1.5
Using xpath 3.2.0
Using rails-html-sanitizer 1.4.2
Using websocket-driver 0.7.5
Using activejob 7.0.0
Using irb 1.4.1
Using selenium-webdriver 4.1.0
Using capybara 3.36.0
Using webdrivers 5.0.0
Using actionview 7.0.0
Using debug 1.4.0
Using jbuilder 2.11.5
Using actionpack 7.0.0
Using activestorage 7.0.0
Using railties 7.0.0
Using sprockets-rails 3.4.2
Using actioncable 7.0.0
Using actionmailer 7.0.0
Using actionmailbox 7.0.0
Using importmap-rails 1.0.1
Using tailwindcss-rails 2.0.3
Using turbo-rails 1.0.0
Using web-console 4.2.0
Using actiontext 7.0.0
Using stimulus-rails 1.0.2
Using rails 7.0.0
Bundle complete! 17 Gemfile dependencies, 69 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Switch development cable to use redis
        gsub  config/cable.yml
Create controllers directory
      create  app/javascript/controllers
      create  app/javascript/controllers/index.js
      create  app/javascript/controllers/application.js
      create  app/javascript/controllers/hello_controller.js
Import Stimulus controllers
      append  app/javascript/application.js
Pin Stimulus
      append  config/importmap.rb
       rails  tailwindcss:install
Add Tailwindcss include tags and container element in application layout
      insert  app/views/layouts/application.html.erb
      insert  app/views/layouts/application.html.erb
      insert  app/views/layouts/application.html.erb
Build into app/assets/builds
      create  app/assets/builds
      create  app/assets/builds/.keep
      append  app/assets/config/manifest.js
      append  .gitignore
Add default config/tailwindcss.config.js
      create  config/tailwind.config.js
Add default app/assets/stylesheets/application.tailwind.css
      create  app/assets/stylesheets/application.tailwind.css
Add default Procfile.dev
      create  Procfile.dev
Ensure foreman is installed
         run  gem install foreman from "."
Successfully installed foreman-0.87.2
Parsing documentation for foreman-0.87.2
Done installing documentation for foreman after 0 seconds
1 gem installed
Add bin/dev to start foreman
      create  bin/dev
Compile initial Tailwind build
         run  rails tailwindcss:build from "."
ERROR: Cannot find the tailwindcss executable for arm64-darwin in /Users/andrewculver/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/tailwindcss-rails-2.0.3/exe
If you're using bundler, please make sure you're on the latest bundler version:

  gem install bundler
  bundle update --bundler

Then make sure your lock file includes this platform by running:

  bundle lock --add-platform arm64-darwin
  bundle install

See `bundle lock --help` output for details.

Output from taking the steps requested above:

andrewculver@Andrews-MacBook-Pro Sites % cd example-application 
andrewculver@Andrews-MacBook-Pro example-application %   gem install bundler

Successfully installed bundler-2.3.4
Parsing documentation for bundler-2.3.4
Done installing documentation for bundler after 0 seconds
1 gem installed
andrewculver@Andrews-MacBook-Pro example-application %   bundle update --bundler

Using rake 13.0.6
Using concurrent-ruby 1.1.9
Using i18n 1.8.11
Using minitest 5.15.0
Using tzinfo 2.0.4
Using activesupport 7.0.0
Using builder 3.2.4
Using erubi 1.10.0
Using mini_portile2 2.6.1
Using racc 1.6.0
Using nokogiri 1.12.5
Using rails-dom-testing 2.0.3
Using crass 1.0.6
Using loofah 2.13.0
Using rails-html-sanitizer 1.4.2
Using actionview 7.0.0
Using rack 2.2.3
Using rack-test 1.1.0
Using actionpack 7.0.0
Using nio4r 2.5.8
Using websocket-extensions 0.1.5
Using websocket-driver 0.7.5
Using actioncable 7.0.0
Using globalid 1.0.0
Using activejob 7.0.0
Using activemodel 7.0.0
Using activerecord 7.0.0
Using marcel 1.0.2
Using mini_mime 1.1.2
Using activestorage 7.0.0
Using mail 2.7.1
Using actionmailbox 7.0.0
Using actionmailer 7.0.0
Using actiontext 7.0.0
Using public_suffix 4.0.6
Using addressable 2.8.0
Using bindex 0.8.1
Using msgpack 1.4.2
Using bootsnap 1.9.3
Using bundler 2.3.4
Using matrix 0.4.2
Using regexp_parser 2.2.0
Using xpath 3.2.0
Using capybara 3.36.0
Using childprocess 4.1.0
Using io-console 0.5.11
Using reline 0.3.1
Using irb 1.4.1
Using debug 1.4.0
Using method_source 1.0.0
Using thor 1.1.0
Using zeitwerk 2.5.3
Using railties 7.0.0
Using importmap-rails 1.0.1
Using jbuilder 2.11.5
Using puma 5.5.2
Using rails 7.0.0
Using redis 4.5.1
Using rexml 3.2.5
Using rubyzip 2.3.2
Using selenium-webdriver 4.1.0
Using sprockets 4.0.2
Using sprockets-rails 3.4.2
Using sqlite3 1.4.2
Using stimulus-rails 1.0.2
Using tailwindcss-rails 2.0.3
Using turbo-rails 1.0.0
Using web-console 4.2.0
Using webdrivers 5.0.0
Bundle updated!
andrewculver@Andrews-MacBook-Pro example-application %   bundle lock --add-platform arm64-darwin

Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Writing lockfile to /Users/andrewculver/Sites/example-application/Gemfile.lock
andrewculver@Andrews-MacBook-Pro example-application %   bundle install

Using rake 13.0.6
Using concurrent-ruby 1.1.9
Using i18n 1.8.11
Using minitest 5.15.0
Using tzinfo 2.0.4
Using activesupport 7.0.0
Using builder 3.2.4
Using erubi 1.10.0
Using mini_portile2 2.6.1
Using racc 1.6.0
Using nokogiri 1.12.5
Using rails-dom-testing 2.0.3
Using crass 1.0.6
Using loofah 2.13.0
Using rails-html-sanitizer 1.4.2
Using actionview 7.0.0
Using rack 2.2.3
Using rack-test 1.1.0
Using actionpack 7.0.0
Using nio4r 2.5.8
Using websocket-extensions 0.1.5
Using websocket-driver 0.7.5
Using actioncable 7.0.0
Using globalid 1.0.0
Using activejob 7.0.0
Using activemodel 7.0.0
Using activerecord 7.0.0
Using marcel 1.0.2
Using mini_mime 1.1.2
Using activestorage 7.0.0
Using mail 2.7.1
Using actionmailbox 7.0.0
Using actionmailer 7.0.0
Using actiontext 7.0.0
Using public_suffix 4.0.6
Using addressable 2.8.0
Using bindex 0.8.1
Using msgpack 1.4.2
Using bootsnap 1.9.3
Using bundler 2.3.4
Using matrix 0.4.2
Using regexp_parser 2.2.0
Using xpath 3.2.0
Using capybara 3.36.0
Using childprocess 4.1.0
Using io-console 0.5.11
Using reline 0.3.1
Using irb 1.4.1
Using debug 1.4.0
Using method_source 1.0.0
Using thor 1.1.0
Using zeitwerk 2.5.3
Using railties 7.0.0
Using importmap-rails 1.0.1
Using jbuilder 2.11.5
Using puma 5.5.2
Using rails 7.0.0
Using redis 4.5.1
Using rexml 3.2.5
Using rubyzip 2.3.2
Using selenium-webdriver 4.1.0
Using sprockets 4.0.2
Using sprockets-rails 3.4.2
Using sqlite3 1.4.2
Using stimulus-rails 1.0.2
Using tailwindcss-rails 2.0.3
Using turbo-rails 1.0.0
Using web-console 4.2.0
Using webdrivers 5.0.0
Bundle complete! 17 Gemfile dependencies, 69 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
andrewculver@Andrews-MacBook-Pro example-application % rails tailwindcss:build
ERROR: Cannot find the tailwindcss executable for arm64-darwin in /Users/andrewculver/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/tailwindcss-rails-2.0.3/exe
If you're using bundler, please make sure you're on the latest bundler version:

  gem install bundler
  bundle update --bundler

Then make sure your lock file includes this platform by running:

  bundle lock --add-platform arm64-darwin
  bundle install

See `bundle lock --help` output for details.

Finally, after trying to edit Gemfile to point directly to github: 'rails/tailwindcss-rails', the result is still the same:

andrewculver@Andrews-MacBook-Pro example-application % bundle install    
Fetching https://github.com/rails/tailwindcss-rails.git
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using rake 13.0.6
...
Using importmap-rails 1.0.1
Using tailwindcss-rails 2.0.3 from https://github.com/rails/tailwindcss-rails.git (at main@86a4dc0)
Bundle complete! 17 Gemfile dependencies, 69 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
andrewculver@Andrews-MacBook-Pro example-application % rails tailwindcss:build                                      
ERROR: Cannot find the tailwindcss executable for arm64-darwin in /Users/andrewculver/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/bundler/gems/tailwindcss-rails-86a4dc04b5bb/exe
If you're using bundler, please make sure you're on the latest bundler version:

  gem install bundler
  bundle update --bundler

Then make sure your lock file includes this platform by running:

  bundle lock --add-platform arm64-darwin
  bundle install

See `bundle lock --help` output for details.
andrewculver@Andrews-MacBook-Pro example-application % 
@andrewculver andrewculver changed the title rails tailwindcss:build fails on M1. rails tailwindcss:build fails on Apple M1. Jan 4, 2022
@flavorjones
Copy link
Member

@andrewculver Sorry you're having problems. Can I ask you to respond with the output of gem env and bundle config (please take care to redact any sensitive data like security tokens)?

@andrewculver
Copy link
Contributor Author

andrewculver commented Jan 4, 2022

@flavorjones Here you go!

Machine one (MacBook Pro, M1 Pro, macOS Monterey)

andrewculver@Andrews-MacBook-Pro example-application % gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.2.22
  - RUBY VERSION: 3.0.2 (2021-07-07 patchlevel 107) [arm64-darwin21]
  - INSTALLATION DIRECTORY: /Users/andrewculver/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0
  - USER INSTALLATION DIRECTORY: /Users/andrewculver/.gem/ruby/3.0.0
  - RUBY EXECUTABLE: /Users/andrewculver/.rbenv/versions/3.0.2/bin/ruby
  - GIT EXECUTABLE: /opt/homebrew/bin/git
  - EXECUTABLE DIRECTORY: /Users/andrewculver/.rbenv/versions/3.0.2/bin
  - SPEC CACHE DIRECTORY: /Users/andrewculver/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/andrewculver/.rbenv/versions/3.0.2/etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - arm64-darwin-21
  - GEM PATHS:
     - /Users/andrewculver/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0
     - /Users/andrewculver/.gem/ruby/3.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/andrewculver/.rbenv/versions/3.0.2/bin
     - /opt/homebrew/Cellar/rbenv/1.2.0/libexec
     - /opt/homebrew/opt/mysql@5.7/bin
     - /Users/andrewculver/.rbenv/shims
     - /Users/andrewculver/.nvm/versions/node/v16.10.0/bin
     - /opt/homebrew/bin
     - /opt/homebrew/sbin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
andrewculver@Andrews-MacBook-Pro example-application % bundle config
Settings are listed in order of priority. The top value will be used.
force_ruby_platform
Set for the current user (/Users/andrewculver/.bundle/config): true

@andrewculver
Copy link
Contributor Author

andrewculver commented Jan 4, 2022

Machine two (MacBook Air, M1, macOS Big Sur)

example-application:$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.1.4
  - RUBY VERSION: 2.7.2 (2020-10-01 patchlevel 137) [arm64-darwin20]
  - INSTALLATION DIRECTORY: /Users/andrewculver/.rvm/gems/ruby-2.7.2
  - USER INSTALLATION DIRECTORY: /Users/andrewculver/.gem/ruby/2.7.0
  - RUBY EXECUTABLE: /Users/andrewculver/.rvm/rubies/ruby-2.7.2/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /Users/andrewculver/.rvm/gems/ruby-2.7.2/bin
  - SPEC CACHE DIRECTORY: /Users/andrewculver/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/andrewculver/.rvm/rubies/ruby-2.7.2/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - arm64-darwin-20
  - GEM PATHS:
     - /Users/andrewculver/.rvm/gems/ruby-2.7.2
     - /Users/andrewculver/.rvm/rubies/ruby-2.7.2/lib/ruby/gems/2.7.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/andrewculver/.rvm/gems/ruby-2.7.2/bin
     - /Users/andrewculver/.rvm/gems/ruby-2.7.2@global/bin
     - /Users/andrewculver/.rvm/rubies/ruby-2.7.2/bin
     - /Users/andrewculver/.rvm/bin
     - /opt/homebrew/bin
     - /opt/homebrew/sbin
     - /Users/andrewculver/.nvm/versions/node/v14.16.1/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - ✂️ Redacted
example-application:$ bundle config
Settings are listed in order of priority. The top value will be used.
build.nokogiri
Set for the current user (/Users/andrewculver/.bundle/config): "--use-system-libraries"

force_ruby_platform
Set for the current user (/Users/andrewculver/.bundle/config): true

gem.ci
Set for the current user (/Users/andrewculver/.bundle/config): "circle"

gem.coc
Set for the current user (/Users/andrewculver/.bundle/config): true

gem.mit
Set for the current user (/Users/andrewculver/.bundle/config): true

gem.rubocop
Set for the current user (/Users/andrewculver/.bundle/config): false

gem.test
Set for the current user (/Users/andrewculver/.bundle/config): "minitest"

@andrewculver
Copy link
Contributor Author

andrewculver commented Jan 4, 2022

@flavorjones Also, I was able to confirm that everything worked as expected on an Intel-based MacBook. (If anyone is lacking M1-based hardware to test on, let me know and we can make some available or I can do testing on my end.)

@andrewculver
Copy link
Contributor Author

I can work around the issue locally by doing the following from the "Standalone CLI: Use Tailwind CSS without Node.js" blog post:

curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-macos-arm64
chmod +x tailwindcss-macos-arm64
mv tailwindcss-macos-arm64 tailwindcss

And then moving that into place like so:

mv tailwindcss-macos-arm64 /Users/andrewculver/.rvm/gems/ruby-2.7.2/gems/tailwindcss-rails-2.0.3/exe/tailwindcss

Then this works:

example-application:$ rails tailwindcss:build

Done in 132ms.

@andrewculver
Copy link
Contributor Author

andrewculver commented Jan 4, 2022

OK, maybe there is something I don't understand about how Bundler is supposed to work, but when I uninstall the gem and then install directly with gem install tailwindcss-rails, I get the correct version of the gem:

example-application:$ gem install tailwindcss-rails
Successfully installed tailwindcss-rails-2.0.3-arm64-darwin
Parsing documentation for tailwindcss-rails-2.0.3-arm64-darwin
Done installing documentation for tailwindcss-rails after 0 seconds
1 gem installed

But even after doing bundle lock --add-platform arm64-darwin, doing a bundle install doesn't install the correct version:

Fetching tailwindcss-rails 2.0.3
...
Installing tailwindcss-rails 2.0.3

And I can confirm it installed the wrong version with gem uninstall tailwindcss-rails:

example-application:$ gem uninstall tailwindcss-rails

Select gem to uninstall:
 1. tailwindcss-rails-2.0.3
 2. tailwindcss-rails-2.0.3-arm64-darwin
 3. All versions

I can reproduce this same issue with the nokogiri gem as well.

@andrewculver
Copy link
Contributor Author

If I remove the ruby entry in the PLATFORMS section of Gemfile.lock, then the correct version of both tailwindcss-rails (and nokogiri) are installed when I run bundle install.

Gemfile.lock looks like this:

PLATFORMS
  arm64-darwin

Output from bundle install is:

Using tailwindcss-rails 2.0.3 (arm64-darwin)

@andrewculver
Copy link
Contributor Author

andrewculver commented Jan 4, 2022

OK, sorry for all the noise here, all of this appears to be because of this setting in ~/.bundle/config:

andrewculver@Andrews-MacBook-Pro ~ % cat ~/.bundle/config
---
BUNDLE_FORCE_RUBY_PLATFORM: "true"

Which... makes sense. 😅 This isn't the default setting, so there's no issue here per se, but I've submitted #122 in case it makes sense to warn others in the same situation.

@flavorjones
Copy link
Member

Thanks for closing the loop here, @andrewculver.

@flavorjones
Copy link
Member

See #123 where I've updated the README with a troubleshooting section.

@DmitrySychev
Copy link

Not sure why this was closed. This is still very much an issue. The solution proposed here runs the code in an x64 emulation. Trying to install this gem on an M1 system has been an absolute nightmare because it can't properly detect the platform.

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

No branches or pull requests

3 participants