Can't run compass after install

22,080

Solution 1

Here's a very important thing about running two or more versions of Ruby on OS X: If you use sudo gem, you will use your OS X default gem from /usr/bin/gem. This is not what you want.

If you use gem alone (without sudo), you should normally use newly installed gem (e.g. the one from the Ruby OS X installer, or the one from RVM, rbenv, whatever method you used to get another Ruby version running). Confirm this by running which -a gem. It should return something like:

/Users/your-username/.rvm/bin/gem
/usr/bin/gem

If your new gem from RVM is not the default (i.e., the first in that list), your RVM installation is broken. Otherwise any call to gem, even without sudo, will still use the /usr/bin/gem and subsequently fail due to insufficient permissions.

So, make sure that all calls to ruby and gem are the RVM versions, and not the system ones. And never use sudo again to install something, because it'll land in your default OS X Ruby.

For RVM specifically, check that it is sourced after all your PATH manipulations are done in the shell's configuration file (usually .profile or .bash_profile on OS X, not sure which one RVM modifies).

Solution 2

I had a similar problem and found that gem list compass -d allowed me to find and symlink compass.

Solution 3

I experienced the same thing. This is what I did to get the compass command working: I added a symbolic link (I have .12.6, changed it to your .12.2):

ln -s /usr/local/lib/ruby/gems/2.0.0/gems/compass-0.12.2/bin/compass /usr/local/bin/compass

Solution 4

I don't feel this is really an answer to my question but at the moment it works... I found compass in my system at /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/compass-0.12.2/bin/ so I added that to ~/.bash_profile at the beginning of export PATH="<here>:/usr/local/bin:other paths" so now I can run the function but I still don't know how to diagnose the system and find the cause of the problem or fix it so It feels like a hack.

I got some useful info from here (stackoverflow), here (apple.stackoverflow) and the ruby rvm help site

Share:
22,080

Related videos on Youtube

Totoro
Author by

Totoro

Updated on September 18, 2022

Comments

  • Totoro
    Totoro over 1 year

    This is a beginner mistake I am sure as I am new to terminal etc. I am trying to get compass working on my mac, I have already installed sass and got it working but when I try to install compass even though it works I can not run it...

    computer-name:~ me$ sudo gem install compass
    Password:
    Successfully installed compass-0.12.2
    Parsing documentation for compass-0.12.2
    1 gem installed
    computer-name:~ me$ compass -v
    -bash: compass: command not found
    computer-name:~ me$ sass -v
    Sass 3.2.12 (Media Mark)
    

    Entering:

    gem list
    

    Also returns:

    compass (0.12.2)
    

    Some things I was thinking were maybe I have a conflict, I originally tried to install without sudo and it worked, I tried again with sudo but it still didn't work.

    My $PATH has:

    computer-name:~ me$ echo $PATH
    /usr/local/bin:/usr/local/sbin:~/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/me/.rvm/bin
    

    The last one .rvm/bin seems to be ruby but does not contain compass (although sass is not there either...)

    I found compass in usr/local/Cellar/ruby/2.0.0-p247/bin/ but looking at tutorials it seems like it should just run, I am assuming I have done something to break the normal functionality and I would like to know how to test for this or fix it.

    Note: sass is in the same folder and sass -v shows the version so I assume it is in the path some how (maybe ruby finds it...)

    • Darius
      Darius over 10 years
      Maybe compass is not in the standard "path" that you can simply invoke from command line? You may need to create a symbolic link to compass from the path, or add compass path into the system path, so you can call 'compass' from anywhere on the system.
    • Totoro
      Totoro over 10 years
      I have looked at the path a little, How would I find compass and add it to the path? I will update my question to include my path.
    • slhck
      slhck over 10 years
      Have you restarted your shell already?
    • Totoro
      Totoro over 10 years
      @slhck I had not... but I just did and it still does not work
    • Totoro
      Totoro over 10 years
      @darius also if you look at the link to install compass it seems like after install I should be able to type compass create <project name> and it should work, but it did not. Which is why I think I have done something to my environment...
  • Totoro
    Totoro over 10 years
    Thanks for the answer, watch returned /usr/local/bin/gem /usr/bin/gem /usr/local/bin/gem (I guess the last is a little redundant..) The first in local is a link to /usr/local/Cellar/ruby/2.0.0-p247/bin/gem so it should work (and it does show up in ruby without sudo, it just does not work on its own.
  • Totoro
    Totoro over 10 years
    I added an answer with more details but voted yours as you gave good advice, I think I need to wipe my hard disc and start over :)
  • Dankwansere
    Dankwansere almost 7 years
    I understand the no sudo thing, but far out - the SASS project says to use it, and that's a fairly official starting point for a lot of people: sass-lang.com/install
  • Finn
    Finn almost 5 years
    Looks like a workaround but its works.