Compass plugin Susy not found - ruby-on-rails

I'm running a Rails 4 app and trying to get compass and susy running. I'm getting the following error:
File to import not found or unreadable: susy.
My gemfile group:
group :assets do
gem 'sass-rails', '~> 4.0.0.beta1'
gem 'compass-rails'
gem 'susy'
...
end
The only CSS line I have (_base.sass)
#import susy
I've run Bundle Install, and my app is using:
Using compass-rails (1.0.3)
Using susy (1.0.7)
Completely lost. I don't have a config.rb file for compass, but from what I gather it isn't necessary after like Rails 3.1/3.2. Any ideas?

You can found the solution in the compass-rails gem documentation:
You have to add the gem compass-susy-plugin instead of susy, like this:
# Gemfile
…
gem 'compass-rails'
gem 'compass-susy-plugin'
…
If you are using Rails 4 do not use group :asset, it has been removed, simply add the previous lines to the Gemfile.
Then run:
$ bundle
$ bundle exec compass install susy
These previous lines will generate files that require susy for you.
And finally add this to your application.rb:
# config/application.rb
config.compass.require "susy"

Related

Phusion error: undefined method `has?' for Sass::Util:Module

I get the following error issued by Phusion when loading a web page:
There was an error while trying to load the gem 'compass-rails'.
Gem Load Error is: undefined method `has?' for Sass::Util:Module
Did you mean? hash
Hash
Backtrace for gem load error is:
/Volumes/Data/htdocs/zetcho/vendor/bundle/gems/compass-0.12.2/lib/compass/sass_extensions/functions/urls.rb:5:in `has?'
The code at the indicated location is:
module Compass::SassExtensions::Functions::Urls
def self.has?(base, instance_method)
Sass::Util.has?(:instance_method, base, instance_method)
end
My gem file contains:
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.2'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.3.18'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Compass for stylesheets
gem 'compass-rails'
# Use the Compass extension susy
gem "sprockets"
gem 'susy'
I've just created the Ruby on Rails site using Rails 5.1.2 and ruby 2.3.1. I have a much older site that works fine with the gem. Did I miss a step in the overall install or is this a bug with compass-rails?
I got the same error when I tried to add a controller:
rails generate controller home index
After more digging around, I found a similar problem. I fixed this one by changing the gem file to:
gem 'compass-rails', github: 'Compass/compass-rails'
Then:
rm gemfile.lock
bundle
It seems that the issue can be found in compass-rails 2.0.0. The version 3.0.2 seems to fix this issues. So a possible solution is :
# Gemfile
gem 'compass-rails', '~> 3.0.2'
Then bundle update compass-rails
This avoids targeting the compass-rails git master branch in favor of an actual release.
I came here having the same issue with a grunt compiling issue trying to use Compass/Sass, if this might help someone, my issue was caused because I had an updated version of Sass (sass-3.7.4) that was higher that the max-version compatible with compass, I uninstalled sass:
gem uninstall sass
Which in turn uninstalled compass, and reinstalled compass letting it choose the right version, and problem solved.
gem install compass

Using susy in Rails

I am using Rails 4.2.5. And I want to use susy.
I've installed some gems required,
gem 'susy'
gem 'compass-rails', '~> 2.0.0'
gem 'compass-susy-plugin'
gem 'sass-rails', '~> 5.0.0'
And in config/application.rb, I've added
require 'susy'
In application.scss
#import "susy";
But I failed to import susy in my scss file. When I give the command sass --watch application.scss:application.css, it shows error application.scss (Line 1: File to import not found or unreadable: susy.).
I may found the answer myself.
Actually, there's no need to convert scss file to css file since the gems we've installed will do that job for us.
By the way, upgrading the compass-rails gem to master may avoid some problem. See this issue.

Ruby on Rails migrate error after add these 3 gems in my gemfile

After adding these 3 gems:
gem 'carrierwave', '0.10.0'
gem 'mini_magick', '3.8.0'
gem 'fog', '1.26.0'
And then I did bundle exec rake db:migrate, I got:
Add this to your Gemfile: gem 'net-ssh' and run bundle install after that. Looks like the particular version of fog you are using is missing the dependency. This is a known bug that has already been fixed in successive versions of the gem.

Can't install Devise

Trying to install Devise and I get the following message "Could not find generator devise:install."
leigh#leigh-VirtualBox:~/Projects/dev01$ bundle install
Using rake 10.3.2
Using i18n 0.6.11
Using json 1.8.1
Using minitest 5.4.0
Using thread_safe 0.3.4
Using tzinfo 1.2.1
Using activesupport 4.1.4
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.4
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.4
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.4
Using activemodel 4.1.4
Using arel 5.0.1.20140414130214
Using activerecord 4.1.4
Using execjs 2.2.1
Using autoprefixer-rails 2.1.1.20140710
Using bcrypt 3.1.7
Using sass 3.2.19
Using bootstrap-sass 3.2.0.0
Using thor 0.19.1
Using railties 4.1.4
Using bootswatch-rails 3.2.0
Using coffee-script-source 1.7.1
Using coffee-script 2.3.0
Using coffee-rails 4.0.1
Using data-confirm-modal 1.0.1 from git://github.com/ifad/data-confirm-modal.git (at master)
Using declarative_authorization 0.5.7
Using orm_adapter 0.5.0
Using warden 1.2.3
Using devise 3.2.4
Using hike 1.2.3
Using multi_json 1.10.1
Using jbuilder 2.1.3
Using jquery-rails 3.1.1
Using bundler 1.6.4
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.1.3
Using rails 4.1.4
Using rdoc 4.1.1
Using sass-rails 4.0.3
Using sdoc 0.4.0
Using spring 1.1.3
Using sqlite3 1.3.9
Using turbolinks 2.2.2
Using uglifier 2.5.3
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
leigh#leigh-VirtualBox:~/Projects/dev01$ rails generate devise:install
Could not find generator devise:install.
leigh#leigh-VirtualBox:~/Projects/dev01$
My Gemfile is:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
gem 'bootstrap-sass', '~> 3.2.0.0'
gem 'bootswatch-rails', '~> 3.2.0'
gem 'autoprefixer-rails'
# Use data-confirm-modal to create custom alert modal popups
gem 'data-confirm-modal', github: 'ifad/data-confirm-modal'
# Use devise for user authentication
gem 'devise'
# Use declarative_authorization for user authorisation
gem 'declarative_authorization'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
Rails version is:
leigh#leigh-VirtualBox:~/Projects/dev01$ rails -v
Rails 4.1.4
leigh#leigh-VirtualBox:~/Projects/dev01$
OS version is:
leigh#leigh-VirtualBox:~/Projects/dev01$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04 LTS
Release: 14.04
Codename: trusty
leigh#leigh-VirtualBox:~/Projects/dev01$
Any ideas as to why the Devise gem won't install after correctly adding it to the Gemfile and running the bundle install?
I did have the server running at one point (rails server) and saw an article stating that attempting to install Devise whilst the server is up could cause strange issues.
I've since tried again with the server down but no difference. I'm sure this is probably happening due to something really simple that I overlooked in the setup, just not sure where else to look.
Any advise or suggestions on where to look next would be great, thanks.
I've done testing using the command below but still received the same error:
leigh#leigh-VirtualBox:~/Projects/dev01$ bundle exec rails g devise:install
Could not find generator devise:install.
The list of installed generators are below and Devise is not listed, how do I get it listed?
leigh#leigh-VirtualBox:~/Projects/dev01$ rails generate
Usage: rails generate GENERATOR [args] [options]
General options:
-h, [--help] # Print generator's options and usage
-p, [--pretend] # Run but do not make any changes
-f, [--force] # Overwrite files that already exist
-s, [--skip] # Skip files that already exist
-q, [--quiet] # Suppress status output
Please choose a generator below.
Rails:
assets
controller
generator
helper
integration_test
jbuilder
mailer
migration
model
resource
scaffold
scaffold_controller
task
Coffee:
coffee:assets
Jquery:
jquery:install
Js:
js:assets
TestUnit:
test_unit:generator
test_unit:plugin
leigh#leigh-VirtualBox:~/Projects/dev01$
same problem today, I removed the 'spring' out from the Gemfile and it did the trick.
or you can turn off your spring first and run rails generate devise:install
OK, I'm still not 100% sure why this worked or what caused the issue in the first place but after running the following commands:
leigh#leigh-VirtualBox:~/Projects/dev01$ gem uninstall devise
Successfully uninstalled devise-3.2.4
leigh#leigh-VirtualBox:~/Projects/dev01$ gem uninstall warden
Successfully uninstalled warden-1.2.3
leigh#leigh-VirtualBox:~/Projects/dev01$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
[... text removed ...]
Installing warden 1.2.3
Installing devise 3.2.4
[... text removed ...]
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
leigh#leigh-VirtualBox:~/Projects/dev01$ rails generate devise:install
create config/initializers/devise.rb
create config/locales/devise.en.yml
Woo Hoo!!! problem solved. Great way to waste a couple of days :-(
What worked for me was:
$ sudo -s
$ bundle exec rails generate devise:install
Without sudo or running the "initializer" /bin/bash --login didn't work. The other solution could be to remove the Gemfile.lock and run bundle install again.
This seems to work on my machine under RVM, but that's with a fresh gemset. If you're using version of Ruby (or an RVM gemset) shared with other Rails installs, you could be having problems there.
As you're using Bundler you should probably use:
bundle exec rails g devise:install
as a general precaution, to ensure you're using the bundle's gems.
I fixed it by adding the following line to my Gemfile:
gem 'devise'
After adding that line, I executed bundle install.
I had the same problem today. I tried uninstalling devise and warden but no luck. Finally I deleted the Gemfile.lock and ran bundle install again and that did the trick.
This will sound ridiculous but open a new terminal window and try again. That's what it ended up being for me. If that still doesn't work, try:
DISABLE_SPRING=1 bundle exec rails g devise:install
I had the same problem today in vscode terminal, try remove the gemfile.lock and if doesn't work, repeate the below process.
You can remove de gemfile and after try bundle install on a new terminal.
I'm think this is a permission problem on vscode.
In first step you can remove the line of devise on gemfile and add again manually -> gemfile 'devise'
Steps:
1.0 try on your terminal.
1.1 remove gemfile.lock.
1.2 run bundle install.
1.3 run rails g devise:install.
If doesn't work
2.0 Quit the terminal e open a new.
2.1 try run the same steps on 1.1 to 1.3
Solved to me.
In my case, I was using:
gem 'rack-cors', :require 'rack-cors'
Then I got the same error but none of the solutions here solved it.
I had to replace it just to be like this:
gem 'rack-cors'
then run
$ bundle install
$ rails generate devise:install
I close my terminal and open a new one.
Then rails generate devise:install
It works this time. It is so weired!
Restarting the console will fix this issue.

Active_Model error in rails

I went back to a rails project I was working on and the command "rails s" started to fail. The Terminal recommended that I run a bundle install. When I did I received the following message:
Bundler could not find compatible versions for gem "activemodel":
In Gemfile:
protected_attributes (>= 0) ruby depends on
activemodel (< 5.0, >= 4.0.0.beta) ruby
rails (>= 0) ruby depends on
activemodel (3.2.12)
I have updated both ruby and rails. I've re-installed active model and restarted my terminal.
My gems file is very simple:
gem 'rails'
gem 'jquery-rails'
gem 'devise'
gem 'simple_form'
gem 'protected_attributes'
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'bootstrap-sass', '~> 2.2.2.0'
gem 'bootstrap'
end
Remove your Gemfile.lock and run
rm Gemfile.lock
and
bundle install
Remove Gemfile.lock
and then bundle
if not works then specify rails version in gemfile.
have you tried running
gem update activemodel
or
bundle update
Bundler has attempted to install Rails 4 and associated gems, but you have some gems fixed at earlier incompatible versions. Either specify a 3.x.x version of Rails or remove the version requirements on your sass-rails and coffee-rails gems.
(I took your Gemfile into a sample application and attempted to run a bundle install--I didn't get the exact error you're seeing but an error of the same cause. Removing the version requirements on those gems solved the issue. Of course that may not be appropriate for your needs!)

Resources