Search code examples
rubylinuxbashrubygemscompass

Compass Installed on WebSpace: Command not found


I want to use Compass in my webspace on a hosted server (no root access). I followed tutorial provided by the hosting company but had no success so far:

In my home dir I created a .gem dir and a .gemrc file:

/* .gemrc in home dir */

gemhome: &GemHome /my/home/dir/.gem
gempath:
   - *GemHome
   - /usr/lib/ruby/gems/1.8

The .bashrc file:

export GEM_HOME=/my/home/dir/.gem
export GEM_PATH=/my/home/dir/.gem:/usr/lib/ruby/gems/1.8

Some checks after re-connecting:

[~] echo $GEM_HOME
/my/home/dir/.gem

[~] echo $GEM_PATH
/my/home/dir/.gem:/usr/lib/ruby/gems/1.8

[~] echo $PATH
?/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Installing Compass

[~] gem install compass

Successfully installed compass-core-1.0.3
Successfully installed compass-import-once-1.0.5
Successfully installed chunky_png-1.3.5
Successfully installed rb-fsevent-0.9.6
Successfully installed ffi-1.9.10
Successfully installed rb-inotify-0.9.5
Successfully installed compass-1.0.3
7 gems installed

Check installation

[~] gem list compass -d

*** LOCAL GEMS ***

compass (1.0.3)
    Authors: Chris Eppstein, Scott Davis, Eric M. Suzanne, Brandon
    Mathis, Nico Hagenburger
    Homepage: http://compass-style.org
    Installed at: /my/home/dir/.gem

    A Real Stylesheet Framework

compass-core (1.0.3)
    Authors: Chris Eppstein, Scott Davis, Eric M. Suzanne, Brandon
    Mathis
    Homepage: http://compass-style.org/reference/compass/
    License: MIT
    Installed at: /my/home/dir/.gem

    The Compass core stylesheet library

compass-import-once (1.0.5)
    Author: Chris Eppstein
    Homepage:
    https://github.com/chriseppstein/compass/tree/master/import-once
    License: MIT
    Installed at: /my/home/dir/.gem

    Speed up your Sass compilation by making @import only import each
    file once.


[~] gem which compass
/my/home/dir/.gem/gems/compass-1.0.3/lib/compass.rb

But Compass cannot be used:

[~] compass
-bash: compass: command not found

Any idea what else I have to do to get compass running? I found several other discussions about this topic but all solutions targeted servers with root access. Since I do not have root access to the server: Any other solutions?

EDIT: Some more information

ls -al ~/.gem
total 32
drwxr-x---  8 u100170 nobody 4096 Nov 19 08:43 .
drwx--x--- 11 u100170 nobody 4096 Nov 19 09:13 ..
drwxr-x---  2 u100170 nobody 4096 Nov 19 08:49 bin
drwxr-x---  2 u100170 nobody 4096 Nov 19 08:49 cache
drwxr-x---  9 u100170 nobody 4096 Nov 19 08:49 doc
drwxr-x--- 10 u100170 nobody 4096 Nov 19 08:49 gems
drwxr-x---  2 u100170 nobody 4096 Nov 19 08:49 specifications
drwxr-x---  3 u100170 nobody 4096 Nov 19 08:43 specs

cd ~/.gem/gems/compass-1.0.3/lib/
ls -al
drwxr-x--- 3 u100170 nobody 4096 Nov 19 08:49 .
drwxr-x--- 6 u100170 nobody 4096 Nov 19 08:49 ..
drwxr-x--- 9 u100170 nobody 4096 Nov 19 08:49 compass
-rw-r--r-- 1 u100170 nobody  676 Nov 19 08:49 compass.rb

compass
-bash: compass: command not found

Solution

  • Your .gem location is not appended to your environmental variable. As seen from the output echo $PATH it isn't appended to your $PATH environmental variable.

    Try appending it to your $PATH variable

    export GEM_HOME=/my/home/dir/.gem/bin
    export GEM_PATH=/my/home/dir/.gem:/usr/lib/ruby/gems/1.8
    
    PATH=$PATH:GEM_HOME:GEM_PATH
    export PATH
    

    Finally do a source ~/.bashrc

    Update

    Appending the correct executable path to the $PATH environment variable will make your executable available within the shell environment.

    In this specific scenario the executable location is /my/home/dir/.gem/bin