Skip to content

Help with tailwindcss-rails setup #235

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
geeekgod opened this issue Dec 18, 2022 · 10 comments
Closed

Help with tailwindcss-rails setup #235

geeekgod opened this issue Dec 18, 2022 · 10 comments

Comments

@geeekgod
Copy link

Hi there, I'm trying to use tailwind in my rails project, but I'm not able to install & run it on my system. It seems like there is some issue with the x86_64-linux platform as I'm using WSL to build my ruby on rails apps.
In my previous projects, I've also tried installing tailwindcss-rails separately following the official guide: https://tailwindcss.com/docs/guides/ruby-on-rails, it didn't work and was throwing the same error.

Here's the command which was used for installation:

rails new task-management-app --database=postgresql --css=tailwind

Here's the log & error which was generated:

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 1 seconds
1 gem installed
Add bin/dev to start foreman
      create  bin/dev
Compile initial Tailwind build
         run  rails tailwindcss:build from "."
["/home/rishabh/.rvm/gems/ruby-3.0.1/gems/tailwindcss-rails-2.0.21-x86_64-linux/exe/x86_64-linux/tailwindcss", "-i", "/mnt/d/Programming/Web/Rails/practice/practice/task-management-app/app/assets/stylesheets/application.tailwind.css", "-o", "/mnt/d/Programming/Web/Rails/practice/practice/task-management-app/app/assets/builds/tailwind.css", "-c", "/mnt/d/Programming/Web/Rails/practice/practice/task-management-app/config/tailwind.config.js", "--minify"]
/home/rishabh/.rvm/gems/ruby-3.0.1/gems/tailwindcss-rails-2.0.21-x86_64-linux/exe/x86_64-linux/tailwindcss: 1: ELF����: not found
/home/rishabh/.rvm/gems/ruby-3.0.1/gems/tailwindcss-rails-2.0.21-x86_64-linux/exe/x86_64-linux/tailwindcss: 4: Syntax error: word unexpected (expecting ")")
rails aborted!
Command failed with exit 2: /home/rishabh/.rvm/gems/ruby-3.0.1/gems/tailwindcss-rails-2.0.21-x86_64-linux/exe/x86_64-linux/tailwindcss

Tasks: TOP => tailwindcss:build
(See full trace by running task with --trace)

Can anyone of you please provide a workaround or any other possible fix?

@Kentasmic
Copy link
Contributor

Have you tried running

bundle lock --add-platform x86_64-linux

@flavorjones
Copy link
Member

@thisisrishabh22 Unfortunately I can't reproduce what you're seeing on an x86_64-linux system. Can you run "bundle env" in that project directory? It would help to understand exactly what versions of gems, rubygems, and bundler you're running. Thank you!

@geeekgod
Copy link
Author

@flavorjones
This is the output of bundle env

Environment

Bundler             2.3.26
  Platforms         ruby, x86_64-linux
Ruby                3.0.1p64 (2021-04-05 revision 0fb782ee38ea37fd5fe8b1f775f8ad866a82a3f0) [x86_64-linux]
  Full Path         /home/rishabh/.rvm/rubies/ruby-3.0.1/bin/ruby
  Config Dir        /home/rishabh/.rvm/rubies/ruby-3.0.1/etc
RubyGems            3.2.15
  Gem Home          /home/rishabh/.rvm/gems/ruby-3.0.1
  Gem Path          /home/rishabh/.rvm/gems/ruby-3.0.1:/home/rishabh/.rvm/rubies/ruby-3.0.1/lib/ruby/gems/3.0.0
  User Home         /home/rishabh
  User Path         /home/rishabh/.gem/ruby/3.0.0
  Bin Dir           /home/rishabh/.rvm/gems/ruby-3.0.1/bin
Tools
  Git               2.25.1
  RVM               1.29.12-next (master)
  rbenv             not installed
  chruby            not installed
  rubygems-bundler  (1.4.5)

Bundler Build Metadata

Built At          2022-11-17
Git SHA           23ec5b8501
Released Version  true

Gemfile

Gemfile

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.0.1"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.4"

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"

# Use postgresql as the database for Active Record
gem "pg", "~> 1.1"

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"

# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"

# Use Tailwind CSS [https://github.com/rails/tailwindcss-rails]
gem "tailwindcss-rails"

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"

# Use Redis adapter to run Action Cable in production
# gem "redis", "~> 4.0"

# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

# Use Sass to process CSS
# gem "sassc-rails"

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

group :development, :test do
  # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
  gem "debug", platforms: %i[ mri mingw x64_mingw ]
end

group :development do
  # Use console on exceptions pages [https://github.com/rails/web-console]
  gem "web-console"

  # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
  # gem "rack-mini-profiler"

  # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
  # gem "spring"
end

group :test do
  # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
  gem "capybara"
  gem "selenium-webdriver"
  gem "webdrivers"
end

Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    actioncable (7.0.4)
      actionpack (= 7.0.4)
      activesupport (= 7.0.4)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
    actionmailbox (7.0.4)
      actionpack (= 7.0.4)
      activejob (= 7.0.4)
      activerecord (= 7.0.4)
      activestorage (= 7.0.4)
      activesupport (= 7.0.4)
      mail (>= 2.7.1)
      net-imap
      net-pop
      net-smtp
    actionmailer (7.0.4)
      actionpack (= 7.0.4)
      actionview (= 7.0.4)
      activejob (= 7.0.4)
      activesupport (= 7.0.4)
      mail (~> 2.5, >= 2.5.4)
      net-imap
      net-pop
      net-smtp
      rails-dom-testing (~> 2.0)
    actionpack (7.0.4)
      actionview (= 7.0.4)
      activesupport (= 7.0.4)
      rack (~> 2.0, >= 2.2.0)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.2.0)
    actiontext (7.0.4)
      actionpack (= 7.0.4)
      activerecord (= 7.0.4)
      activestorage (= 7.0.4)
      activesupport (= 7.0.4)
      globalid (>= 0.6.0)
      nokogiri (>= 1.8.5)
    actionview (7.0.4)
      activesupport (= 7.0.4)
      builder (~> 3.1)
      erubi (~> 1.4)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.1, >= 1.2.0)
    activejob (7.0.4)
      activesupport (= 7.0.4)
      globalid (>= 0.3.6)
    activemodel (7.0.4)
      activesupport (= 7.0.4)
    activerecord (7.0.4)
      activemodel (= 7.0.4)
      activesupport (= 7.0.4)
    activestorage (7.0.4)
      actionpack (= 7.0.4)
      activejob (= 7.0.4)
      activerecord (= 7.0.4)
      activesupport (= 7.0.4)
      marcel (~> 1.0)
      mini_mime (>= 1.1.0)
    activesupport (7.0.4)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 1.6, < 2)
      minitest (>= 5.1)
      tzinfo (~> 2.0)
    addressable (2.8.1)
      public_suffix (>= 2.0.2, < 6.0)
    bindex (0.8.1)
    bootsnap (1.15.0)
      msgpack (~> 1.2)
    builder (3.2.4)
    capybara (3.38.0)
      addressable
      matrix
      mini_mime (>= 0.1.3)
      nokogiri (~> 1.8)
      rack (>= 1.6.0)
      rack-test (>= 0.6.3)
      regexp_parser (>= 1.5, < 3.0)
      xpath (~> 3.2)
    concurrent-ruby (1.1.10)
    crass (1.0.6)
    date (3.3.3)
    debug (1.7.0)
      irb (>= 1.5.0)
      reline (>= 0.3.1)
    erubi (1.11.0)
    globalid (1.0.0)
      activesupport (>= 5.0)
    i18n (1.12.0)
      concurrent-ruby (~> 1.0)
    importmap-rails (1.1.5)
      actionpack (>= 6.0.0)
      railties (>= 6.0.0)
    io-console (0.6.0)
    irb (1.6.1)
      reline (>= 0.3.0)
    jbuilder (2.11.5)
      actionview (>= 5.0.0)
      activesupport (>= 5.0.0)
    loofah (2.19.1)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.8.0)
      mini_mime (>= 0.1.1)
      net-imap
      net-pop
      net-smtp
    marcel (1.0.2)
    matrix (0.4.2)
    method_source (1.0.0)
    mini_mime (1.1.2)
    minitest (5.16.3)
    msgpack (1.6.0)
    net-imap (0.3.2)
      date
      net-protocol
    net-pop (0.1.2)
      net-protocol
    net-protocol (0.2.1)
      timeout
    net-smtp (0.3.3)
      net-protocol
    nio4r (2.5.8)
    nokogiri (1.13.10-x86_64-linux)
      racc (~> 1.4)
    pg (1.4.5)
    public_suffix (5.0.1)
    puma (5.6.5)
      nio4r (~> 2.0)
    racc (1.6.1)
    rack (2.2.4)
    rack-test (2.0.2)
      rack (>= 1.3)
    rails (7.0.4)
      actioncable (= 7.0.4)
      actionmailbox (= 7.0.4)
      actionmailer (= 7.0.4)
      actionpack (= 7.0.4)
      actiontext (= 7.0.4)
      actionview (= 7.0.4)
      activejob (= 7.0.4)
      activemodel (= 7.0.4)
      activerecord (= 7.0.4)
      activestorage (= 7.0.4)
      activesupport (= 7.0.4)
      bundler (>= 1.15.0)
      railties (= 7.0.4)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.4.4)
      loofah (~> 2.19, >= 2.19.1)
    railties (7.0.4)
      actionpack (= 7.0.4)
      activesupport (= 7.0.4)
      method_source
      rake (>= 12.2)
      thor (~> 1.0)
      zeitwerk (~> 2.5)
    rake (13.0.6)
    regexp_parser (2.6.1)
    reline (0.3.2)
      io-console (~> 0.5)
    rexml (3.2.5)
    rubyzip (2.3.2)
    selenium-webdriver (4.7.1)
      rexml (~> 3.2, >= 3.2.5)
      rubyzip (>= 1.2.2, < 3.0)
      websocket (~> 1.0)
    sprockets (4.1.1)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.4.2)
      actionpack (>= 5.2)
      activesupport (>= 5.2)
      sprockets (>= 3.0.0)
    stimulus-rails (1.2.1)
      railties (>= 6.0.0)
    tailwindcss-rails (2.0.21-x86_64-linux)
      railties (>= 6.0.0)
    thor (1.2.1)
    timeout (0.3.1)
    turbo-rails (1.3.2)
      actionpack (>= 6.0.0)
      activejob (>= 6.0.0)
      railties (>= 6.0.0)
    tzinfo (2.0.5)
      concurrent-ruby (~> 1.0)
    web-console (4.2.0)
      actionview (>= 6.0.0)
      activemodel (>= 6.0.0)
      bindex (>= 0.4.0)
      railties (>= 6.0.0)
    webdrivers (5.2.0)
      nokogiri (~> 1.6)
      rubyzip (>= 1.3.0)
      selenium-webdriver (~> 4.0)
    websocket (1.2.9)
    websocket-driver (0.7.5)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.5)
    xpath (3.2.0)
      nokogiri (~> 1.8)
    zeitwerk (2.6.6)

PLATFORMS
  x86_64-linux

DEPENDENCIES
  bootsnap
  capybara
  debug
  importmap-rails
  jbuilder
  pg (~> 1.1)
  puma (~> 5.0)
  rails (~> 7.0.4)
  selenium-webdriver
  sprockets-rails
  stimulus-rails
  tailwindcss-rails
  turbo-rails
  tzinfo-data
  web-console
  webdrivers

RUBY VERSION
   ruby 3.0.1p64

BUNDLED WITH
   2.3.26

@geeekgod
Copy link
Author

@Kentasmic

I've tried running bundle lock --add-platform x86_64-linux but it didn't help either.

@flavorjones
Copy link
Member

Well you've got the right gem version and platform installed:

    tailwindcss-rails (2.0.21-x86_64-linux)

So I'm not sure why this isn't working properly. It's possible the files are corrupted on disk. Can you try:

gem uninstall --force tailwindcss-rails
gem install tailwindcsss-rails
tailwindcss --help

and paste the output here?

@geeekgod
Copy link
Author

Hi @flavorjones

The outputs of the commands you shared are given below:

1. gem uninstall --force tailwindcss-rails

Output

Successfully uninstalled tailwindcss-rails-2.0.14-x86_64-linux
Remove executables:
        tailwindcss

in addition to the gem? [Yn]  Y
Removing tailwindcss

2. gem install tailwindcss-rails

Output

Fetching tailwindcss-rails-2.0.21-x86_64-linux.gem
Successfully installed tailwindcss-rails-2.0.21-x86_64-linux
Parsing documentation for tailwindcss-rails-2.0.21-x86_64-linux
Installing ri documentation for tailwindcss-rails-2.0.21-x86_64-linux
Done installing documentation for tailwindcss-rails after 1 seconds
1 gem installed

3. tailwindcss --help

Output

["/home/rishabh/.rvm/gems/ruby-3.0.1/gems/tailwindcss-rails-2.0.21-x86_64-linux/exe/x86_64-linux/tailwindcss", "--help"]
/home/rishabh/.rvm/gems/ruby-3.0.1/gems/tailwindcss-rails-2.0.21-x86_64-linux/exe/x86_64-linux/tailwindcss: 1: ELF����: not found
/home/rishabh/.rvm/gems/ruby-3.0.1/gems/tailwindcss-rails-2.0.21-x86_64-linux/exe/x86_64-linux/tailwindcss: 4: Syntax error: word unexpected (expecting ")")

Thankyou!

@flavorjones
Copy link
Member

flavorjones commented Dec 20, 2022

This is strange to me, and I'm wondering if this is something strange with how WSL handles some linux binaries.

If you download the tailwindcss-linux-x64 executable from https://github.com/tailwindlabs/tailwindcss/releases, are you able to run that binary?

@geeekgod
Copy link
Author

@flavorjones
This is the output I got while running tailwindcss-linux-x64

$ sudo ./tailwindcss-linux-x64
./tailwindcss-linux-x64: 1: ELF����: not found
./tailwindcss-linux-x64: 4: Syntax error: word unexpected (expecting ")")

@flavorjones
Copy link
Member

OK - then can I ask you to file a bug report upstream? This is the binary that we're repackaging, so if the upstream binary is causing the problem, that team needs to be aware and prioritize a fix.

@flavorjones
Copy link
Member

Resolved in upstream discussion.

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