RVM Sass Compass issue with localhost sites

2019-04-06 05:56发布

问题:

I have spent over 5 hours trying to solve this and feel that since I haven't done it before I should ask some help now...

I have a site I inherited with Sass/Compass put together. I have it set up on my localhost and it works fine for that site.

I have a second localhost site I want to use it on. So I went to the theme folder in terminal - (/sites/all/theme/newtheme/) I tried to start watching a sass folder with compass and keep getting these errors...

/Library/Ruby/Site/1.8/rubygems/dependency.rb:298:in `to_specs': Could not find 'compass'     
(>= 0) among 12 total gem(s) (Gem::LoadError)
from /Library/Ruby/Site/1.8/rubygems/dependency.rb:309:in `to_spec'
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_gem.rb:53:in `gem'
from /usr/bin/compass:18

I am using rvm rubies 1.9.3 and sass/compass have been installed. I have searched and tested many ideas and I am lost as to what to do. I really want to get into sass but I am losing out with timing to get into it and need to solve this issue. I would love any help you can give and will research and test anything.

Update: I am using rvm and I am using ruby-1.9.3-p484.Here is my gem list.

LOCAL GEMS 
bigdecimal (1.1.0)
bundler (1.5.3)
bundler-unload (1.0.2)
celluloid (0.15.2)
chunky_png (1.3.0)
ompass (0.12.2)
executable-hooks (1.3.1)
ffi (1.9.3)
fssm (0.2.10)
gem-wrappers (1.2.4)
io-console (0.3)
json (1.5.5)
listen (2.4.1)
minitest (2.5.1)
rake (0.9.2.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.3)
rdoc (3.9.5)
rubygems-bundler (1.4.2)
rvm (1.11.3.9)
sass (3.3.0.rc.4, 3.2.14, 3.2.13)
timers (1.1.0)

When I run $compass -v, or $compass watch I get this error.

ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:135:in `require': cannot load such file -- sass/script/node (LoadError)
rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:144:in `require'
gems/ruby-1.9.3-p484@global/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches/browser_support.rb:1:in `<top (required)>'
rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
gems/ruby-1.9.3-p484@global/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches.rb:2:in `block in <top (required)>'
gems/ruby-1.9.3-p484@global/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches.rb:1:in `each'
gems/ruby-1.9.3-p484@global/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches.rb:1:in `<top (required)>'
rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
gems/ruby-1.9.3-p484@global/gems/compass-0.12.2/lib/compass/sass_extensions.rb:9:in `<top (required)>'
rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
gems/ruby-1.9.3-p484@global/gems/compass-0.12.2/lib/compass.rb:5:in `block in <top (required)>'
gems/ruby-1.9.3-p484@global/gems/compass-0.12.2/lib/compass.rb:4:in `each'
gems/ruby-1.9.3-p484@global/gems/compass-0.12.2/lib/compass.rb:4:in `<top (required)>'
rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
gems/ruby-1.9.3-p484@global/gems/compass-0.12.2/bin/compass:20:in `block in <top (required)>'
gems/ruby-1.9.3-p484@global/gems/compass-0.12.2/bin/compass:8:in `fallback_load_path'
gems/ruby-1.9.3-p484@global/gems/compass-0.12.2/bin/compass:19:in `<top (required)>'
rubies/ruby-1.9.3-p484/bin/compass:23:in `load'
rubies/ruby-1.9.3-p484/bin/compass:23:in `<main>'
gems/ruby-1.9.3-p484@global/bin/ruby_executable_hooks:15:in `eval'
gems/ruby-1.9.3-p484@global/bin/ruby_executable_hooks:15:in `<main>'

One thing I think is the path to compass. However when I try to use ruby-1.9.3-p484@global I get the same results.

I have been searching, testing, installing and uninstalling to try to figure out the one step I am missing. Please share any ideas. Thanks

回答1:

You need to uninstall sass and reinstall it with the following:

gem uninstall sass
gem install sass --no-ri --no-rdoc
gem install compass --no-ri --no-rdoc 


回答2:

This somewhat goes along with @user24793's answer to himself, but I just had this exact same issue happen out of absolute no where for a local dev environment that was working fine a few days ago, except my issue was with sass rather than compass. I am also using RVM, and the other answers here didn't help me either.

What happened in my case was while my main version of ruby is 2.1.5 and my gem path was located at ~/.rvm/gems/ruby-2.1.5, there was a secondary version of ruby installed in a subdirectory of my main ruby that was looking in ~/.rvm/rubies/ruby-2.1.5/lib/ruby/gems/2.1.0 which predictably didn't have sass in it. I'm not sure when this happened as it was working fine last week, and it appeared to only have affected this one project.

I'm no Ruby expert, so after doing a ton of searching I was able to find other threads similar but with other answers, one such thread being Rails: Could not find railties. Highlights from that one that coincidentally did not work for me but seem promising are:

  • Try installing without sudo if you previously installed using sudo
  • rvm reinstall X.X.X X's being whatever version you're using, then gem install {gem}. I've got a ton of projects at the moment so I wasn't able to try this one myself, but after I finish my active projects I'm probably going to give this a go.
  • rvm implode however this will force you to do a complete reinstall of rvm. Again, too many projects to try at the moment.

Since I've now been halted on this project for the last 3 days because of this, I don't have a gemrc file, nothing I could find actually worked, and it seems like it's ultimately just an incorrectly installed version of ruby that got added by this project, I had to take drastic measures by forcing the gem path for the secondary ruby to the correct gem path.

I don't recommend this as a solid way around the problem, but if you're blocked on a project because of this, don't have a gemrc file or any way of changing the path of a ruby version that was installed inside of a ruby version, this works as a bit of a hack but I highly suggest after you finish your project you try reinstalling rvm/ruby and doing more research.

Anyway, I'm sure there's another way around this where you can get into the cli for the alternate ruby and change the gem path, but I wasn't able to find one and I needed this fixed asap. I would be extremely happy if someone could let me know how that is possible, but otherwise you have to find your defaults.rb file, which I found at:

~/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/defaults.rb

On line 75 it defines the users home directory gem path, and on line 93 it defines the default gem path. The users home directory gem path wasn't even an existing folder, so I swapped it from:

def self.user_dir
  parts = [Gem.user_home, '.gem', ruby_engine]
  parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty?
  File.join parts
end

To:

def self.user_dir
  parts = [Gem.user_home, '.rvm/gems/ruby-2.1.5']
  File.join parts
end

This instantly fixed my problem; but again my circumstances are very rare and I only recommend doing this if you've got no other alternative and are dealing with a secondary version of ruby that has no gemrc file or command line that you can tap into.



回答3:

Long story short. Problem solved.

Since I had to figure this all out quickly and in a reverse engineering direction, along with websites helping with basics and stackoverflow helping with some details, hopefully this helps some non-developer.

First, make sure you understand that RVM allows multiple versions of Ruby, and even though Ruby 1.8 might already be on your machine, it is old and you should download a newer version.

Secondly, There are versions of Sass and Compass that need to work together and some conflict. That is not apart of the websites selling how easy it is to use and set up.

Lastly, when setting it up for multiple sites on you local host. Each site is slightly different. Especially if you are using Drupal, and different themes, versus something hard coded.

After the long and short of it, here are a few sites that helped and steps I took:

RVM - http://rvm.io/
Decent Tut - http://www.rosehosting.com/blog/install-ruby-sass-and-compass/

First learn some commands:

ruby -v
rvm list
rvm gemdir
gem list
rvm all do gem list # (this is - I think - getting into gem sets. Something I need to read up on.)
gem install gem-name -v version #
sass -v
compass -v
compass watch # after everything is set up
bundle exec compass watch # to initial the watch of that folder.
bundle check
bundle install # installs everything you need. I ran into a problem with the http_parser and had to install singularly but then ran the bundle install and the rest went fine.

These will help you with Terminal and figuring out what you have and waht you are missing.

The errors I received were good but not for a noob! So, try to take the first line more serious. What ever is in there is something missing, at least it was for the above.

Hopefully that helps someone like me to get through it.



回答4:

I just downgraded ruby to from 2.1.5 to 2.0.0 and that solved my problem. I have to stay on older sass and compass versions as my project uses them so upgrading was not solution for me.



回答5:

The compass page should help actually http://compass-style.org/install/

it's not enough to have compass installed, if you starting a new project you have to start a compass project by running the following command

$ compass create <myproject>

You will get a simple folder structure and a config.rb file