Problem Installing Tailwindcss into rails 7 app (Windows 10 Dev Environemnt) - ruby-on-rails

I am getting an odd error when trying to install TailwindCss into my Rails 7 Ruby 3.1.2 app. I do not understand how to correct this so it compiles / installs properly, any assistance here would be greatly appreciated. Error message below:
Add Tailwindcss include tags and container element in application layout
File unchanged! The supplied flag value not found! app/views/layouts/application.html.erb
Build into app/assets/builds
exist app/assets/builds
identical app/assets/builds/.keep
File unchanged! The supplied flag value not found! app/assets/config/manifest.js
File unchanged! The supplied flag value not found! .gitignore
File unchanged! The supplied flag value not found! Procfile.dev
Add bin/dev to start foreman
identical bin/dev
Compile initial Tailwind build
run rails tailwindcss:build from "."
["/home/starfixx/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/tailwindcss-rails-2.0.16-x86_64-linux/exe/x86_64-linux/tailwindcss", "-i", "/mnt/c/code/telipaxx/app/assets/stylesheets/application.tailwind.css", "-o", "/mnt/c/code/telipaxx/app/assets/builds/tailwind.css", "-c", "/mnt/c/code/telipaxx/config/tailwind.config.js", "--minify"]
/home/starfixx/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/tailwindcss-rails-2.0.16-x86_64-linux/exe/x86_64-linux/tailwindcss: 1: ELF: not found
/home/starfixx/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/tailwindcss-rails-2.0.16-x86_64-linux/exe/x86_64-linux/tailwindcss: 4: Syntax error: word unexpected (expecting ")")
rails aborted!
Command failed with exit 2: /home/starfixx/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/tailwindcss-rails-2.0.16-x86_64-linux/exe/x86_64-linux/tailwindcss
Tasks: TOP => tailwindcss:build
(See full trace by running task with --trace)
Thanks in advance for all your suggestions / assistance.

I am also using Windows 10 and the fix for me was to change my WSL version from 1 to 2 using Windows PowerShell:
wsl --set-version <distro name> 2
You can find your distro name and version by running in Windows PowerShell:
wsl -l -v
For details please visit Microsoft guide: https://learn.microsoft.com/en-us/windows/wsl/install.
PostgreSQL problem: If you are running PostgreSQL on windows you will face an error during connection, you must setup host in database.yml using this guide: WSL2 use "localhost" to access Windows service , and setup route using this: WSL2 and PostgreSQL connection.

You can check out the Tailwind CSS and Rails docs by visiting this page.
https://tailwindcss.com/docs/guides/ruby-on-rails
Follow this steps:
Install the gem.
gem "tailwindcss-rails", "~> 2.0"
Run bundle install.
Run rails tailwindcss:install
This will generate some files where you can add some tailwindcss colors, CSS file, etc, (config/tailwind.config.js)
After that, you have to run rails tailwindcss:build
This compile your tailwindcss configuration.
Add some test code.
Finally, run rails assets:precompile.
This command will compile all your JS and CSS of your JS.
Enjoy!

Related

Not able install & setup tailwindcss-rails in ruby on rails app

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.
Can anyone of you please provide a workaround or any other possible fix?
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)
The quickest way to start using Tailwind CSS in your Rails project is to use Tailwind CSS for Rails by running rails new my-app --css tailwind. This will automatically configure your Tailwind setup based on the official Rails example. If you'd like to configure Tailwind manually, continue with the rest of this guide.follow the steps properly.

Getting an error while installing Ruby On Rails on Mac OS X 10.15 Catalina

I tried installing Ruby on Rails on my OS X Catalina (10.15) and had two issues that are maybe related. On the final step here it says
"Mojave changed the location of header files necessary for compiling C extensions. You might need to run the following command to install pg, nokogiri, or other gems that require C extensions:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
"
For that step i do not have a folder packages under my command line tools folder so this line i could not run. So I ignored it and continue with the instructions. Then when i got to the last command in this instructions guide "rails server" the server tried to run and i got this run time error:
/Users/yoramaharony/.rvm/gems/ruby-2.7.0/gems/webpacker-4.2.2/lib/webpacker/configuration.rb:95:in `rescue in load': Webpacker configuration file not found /Users/yoramaharony/dev/myapp/config/webpacker.yml. Please run rails webpacker:install Error: No such file or directory # rb_sysopen - /Users/yoramaharony/dev/myapp/config/webpacker.yml (RuntimeError)
I do not have experience running terminal command but i am pretty sure i followed the guide diligently so why the last step is giving me error.
Thank you
You need to run bundle exec rails webpacker:install in order to set up Webpacker dependencies. Rails 6 introduces Webpacker as the default JavaScript tool for bundling JavaScript code. You could read more about it in this blog by Prathamesh Sonpatki

bin/rails giving error that 'bin' is not recognized as internal

I am a beginner trying to learn and do the Ruby on Rails tutorials (http://guides.rubyonrails.org/getting_started.html#installing-rails)
and for all the bin commands in the command window such as
$ bin/rails --version
or
$ bin/rails server
I am getting the error " 'bin' is not recognized as an internal or external command, operable program or batch file.'
I just installed the latest version of Ruby so I've tried running
rake rails:update:bin
and I also added the PATH variable C:\RailsInstaller\Ruby1.9.3\bin to my environment variables.
I'm still getting the same error.
Thank you in advance!
You are getting those errors because you are on Windows. In this case you have to pass the scripts under the bin folder directly to the Ruby interpreter like this:
ruby bin\rails server
If you have added the bin directory to your PATH variable, then you don't need to use it in the command. Just type $ rails --version, etc.

"rails server" command is not getting recognized

I am new to rails and am following the tutorial posted on the ROR website. Everything is working fine until I try and load up my rails application on the localhost. Every time enter $ rails server I get a long list of possible commands and functions. When I check my localhost:3000 and 127.0.0.1:3000, nothing seems to be connected.
Upon digging deeper, I have tried almost everything everyone else has tried. I am running the command in the same path as my new rails application. Furthermore, when I enter in nonsense after the $ rails command I get the same list of possible commands and functions. So I get the feeling that rails is not recognizing the server command.
Here are my versions:
Ruby 1.9.3 p374
Rails 3.2.11
Why isn't the server command recognized?
First of all you have to move to the project directory and install bundle with the following command:
bundle install
Then start the server:
rails server
I had the same problem. rails server or simply rails s only works when you are in the right directory.
Type pwd (present working directory) to see where you currently are.
Type cd and the rest of the direction to the correct directory.
(for example, "cd workspace/learn-rails")
Type rails server or rails s.
Check http://localhost:3000.
Please exit from terminal and then restart the terminal.
Then check the directory path i.e just type pwd it will show the current directory path.
And if directory is correct on try again running command like bundle install & rails server
I think this should be work.

Rails using gitbash and ruby installer. rails command not found

I am trying to get Ruby on Rails going on my Windows 7 machine. I am using gitbash and have install ruby using ruby installer. All my gems have installed successfully (Rails 3.0.7), but when I try to run a command like rails s I get sh.exe": rails: command not found
echo $PATH gives me:
/c/Users/Dave/bin:.:/usr/local/bin:/mingw/bin:/bin:/c/Ruby192/bin:/c/Program Files/Common Files/Microsoft Shared/Windows Live:/c/Program Files/NVIDIA Corporation/PhysX/Common:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/c/Program Files/Common Files/Adobe/AGL:/c/Program Files/QuickTime/QTSystem/:/c/Program Files/Common Files/Microsoft Shared/Windows Live
Since the path for Ruby is in there I am at a bit of a loss for how to be able to start the rails server.
running gem install rails fixed it
This Problem confuses basic developers. Because they simultaneously use both Git Bash & Command Prompt with Ruby and Rails.
When we type "Rails any command" in CMD with Ruby and Rails, we don't see any failure. But if we run the same command in gitbash means, we get the result "Command not found". Running "Gem install rails" fixs it for gitbash users as the above sayings.
For those who use both Git and Cmd with ROR, they can get the command executed anyhow by running on any of the one...

Resources