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.
Related
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!
I'm using Rails 5.1.4 with Ruby 2.4.2 and following this tutorial about Rails modern front end set up; https://evilmartians.com/chronicles/evil-front-part-1.
This instructs me to start a new rails project with;
rails new evil_chat --skip-coffee --skip-sprockets --skip-turbolinks --webpack --database=postgresql -T
Having done so, though i do find gem 'webpacker' in my gemfile, I do not have app/javascript/... or config/webpacker.yml in my new app's directory.
Any ideas what I've done wrong?
Visit the installation guide. Your command is correct and you need to now install Webpacker with the command
bundle exec rails webpacker:install
Continue onto the README and review the development development guide. This will help you start your webpacker's development server.
If you want to include a specific JS framework with your initial installation you can pass it in the webpack option like so:
--webpack=vue
Or if webpack was already installed use the command bundle exec rails webpacker:install:vue on the existing Rails app.
I'm getting the above error when trying to run foreman start from command line.
I installed the gem:
gem install foreman
Then defined a procfile. Why am I getting this error? When I run foreman list, I get:
Available commands:
build Commission Forman to build a new Laravel app for you
help Displays help for a command
list Lists commands
scaffold Generate a scaffolded Foreman template file
self-update Updates the application.
https://github.com/Indatus/foreman you use different foreman :)
https://github.com/ddollar/foreman it's what you need
Im about to start work on another web application, I change directories to
/rails_projects
and enter
rails new blank
I then get this error
Error: Command not recognized
Usage: rails COMMAND [ARGS]
The common rails commands available for engines are:
generate Generate new code (short-cut alias: "g")
destroy Undo code generated with "generate" (short-cut alias: "d")
All commands can be run with -h for more information.
If you want to run any commands that need to be run in context
of the application, like `rails server` or `rails console`,
you should do it from application's directory (typically test/dummy).
I have reinstalled rails, and still same error, any ideas?
UPDATE:
It actually give me the same error when I type just
rails -h
rails
in cmd
For anyone with a similar error that may land here, this fixed it for me:
rake rails:update:bin
This will generate "new" versions of the binaries. Just say Yes when it inquires you to replace them.
I ran into a similar issue when trying to upgrade a Rails Engine from 3.2 to 4.1.
The culprit was the presence of script/rails which contained:
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/my_project/engine', __FILE__)
require 'rails/all'
require 'rails/engine/commands'
The problem line is there at the end: require 'rails/engine/commands. That was not allowing the full Rails CLI to load which omitted the new command. Removing that file solved my problem.
I'm pretty sure this wasn't the cause of your specific problem, but the symptoms were the same as mine and this was the first link in Google for the error message. Just passing along my findings to help anyone else that runs into this same situation.
It looks like the rails command believes it's inside of a rails engine, which is why a different set of commands are available to you. Notice the 'commands available for engines' text. New is not a command available for engines. I'm not sure why rails thinks the directory you're in is an engine, but likely your directory structure is mixed up somehow.
If anyone runs into this error and needs a last resort plan.
I ended up uninstalling rails, rvm, and installing a newer version of ruby and new gemset.
rvm implode
gem uninstall rails -v=4.0.2
gem uninstall railities
install rvm :
curl -L https://get.rvm.io | bash -s
rvm get stable
for mac:
brew install libtool libxslt libksba openssl
brew install libyaml
install ruby:
rvm install 2.0.0 --with-openssl-dir=$HOME/.rvm/usr
if you have error
rvm install 2.0.0 --with-openssl-dir=$HOME/.rvm/opt/openssl
install new ruby gems from website. Unpackage it then go to folder and run
ruby setup.rb
gem update --system 2.1.9
install rails (you can choose your version)
gem install rails --version 4.0.2
gem install railties
I did this, and now system is working normal again.
Create another directory and run $ruby -v, check which version is available. Now run rails new app_name. Try once after closing the terminal and restarting.
This happen to me when a require error occurred in a gem (dependency) while loading.
I've successfully made a new application with the rails new command from a clone of the Rails master branch. The app looks fine, and is definitely Rails 4. But when I try to run any other rails command, the prompt gives me:
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
... etc etc
I've tried rails, bundle exec rails, and bin/rails, all give the same prompt. My steps for creating a new Rails 4 app were:
Clone the Rails master branch to my local machine
Create a new rvm gemset, and use it (1.9.3)
Run rails/railties/bin/rails new myapp --edge -T --skip-index-html
cd myapp and run bundle install and bundle update just to be sure
Run any rails command
What am I doing wrong? rvm-prompt suggests I am using the right gemset. One thing I did notice is that even when I remove jbuilder from my Gemfile and run a bundle update, it still appears in my gem list. Is something wrong with my rvm here?
rails-v output is 'Rails 4.0.0.beta'
See my first comment here, it contains a possible fix : https://github.com/rails/rails/issues/9715
This looks like a bug, report back to ruby on rails issues tracking: https://github.com/rails/rails/issues
I had this issue when my 'bin' folder was missing.