How to install libsass on Ubuntu 16.04?

14,339

I too was trying to find sassc in Ubuntu 16.04 to build the adapta theme but I couldn't. It seems that package is available for Ubuntu 16.10 or greater, but not for 16.04.

So, what can you do? While I was searching, I found blog post which shows the path, but it didn't work as instructed on that post.

I'm describing the steps I followed here.

Step 1: Clone libsass, sassc, sass-spec repositories

I'm installing those library for all users. So, I choose, /usr/local/lib directory.

cd /usr/local/lib/
sudo git clone https://github.com/sass/sassc.git --branch 3.4.2 --depth 1
sudo git clone https://github.com/sass/libsass.git --branch 3.4-stable --depth 1
sudo git clone https://github.com/sass/sass-spec.git --depth=1

You need to use sudo because /usr/local/lib directory is root writable only.

Step 2: Set the environment variable

I don't know if this step was necessary, but I did it eventually. The blog post's instruction will give error if you were not using a root shell.

echo 'SASS_LIBSASS_PATH="/usr/local/lib/libsass"' | sudo tee -a /etc/environment

This sets the SASS_LIBSASS_PATH env variable which will be used while compiling sassc to find the required libraries.

source the changed file

source /etc/environment

Step 3: Build libsass

You need to first build the libsass libraries. While you're in the /usr/local/lib directory use this command to build it

sudo make -C libsass

Step 4: Build and install sassc

After step 3 is finished, while still on the /usr/local/lib directory, use this command to build sassc.

sudo make -C sassc

This will generate sassc binary in sassc/bin/ folder. Now use this command to make the binary available globally.

sudo make -C sassc install

That's it. Now from anywhere, try sassc command to see if it's recognized.

Shortcut

When I finished building and started writing this answer, I found a PPA for sassc used by the adapta theme maker tista. And it was for 16.04 Xenial. Though the version is older 3.2.3, it will do the job I think.

Here is the PPA link: https://launchpad.net/~tista/+archive/ubuntu/build

Have fun!


Useful links

  1. sassc build instruction - https://github.com/sass/sassc/blob/master/docs/building/unix-instructions.md
  2. Reported issue with libsass build instruction - https://github.com/sass/libsass/issues/1556
Share:
14,339

Related videos on Youtube

nizz0k
Author by

nizz0k

I have a background in social-sciences and mapping applications. I am relatively new to drupal, but have dabbled in various web technologies for a while.

Updated on September 18, 2022

Comments

  • nizz0k
    nizz0k over 1 year

    I've been trying to install libsass on my dev machine to use sassc, but I'm not having any success. Most of the tutorials that I have found are from earlier this year and don't seem to work (for me) (e.g install libsass ubuntuask ubuntu This issue for me seems to be running the make file from the sassc directory.

    nizzok@nizzok-ThinkPad-X201:~/sassc$ make
    make BUILD="static" -C /home/nizzok/libsass
    make[1]: Entering directory '/home/nizzok/libsass'
    mkdir lib
    mkdir: cannot create directory ‘lib’: Permission denied
    Makefile:227: recipe for target 'lib' failed
    make[1]: *** [lib] Error 1
    make[1]: Leaving directory '/home/nizzok/libsass'
    Makefile:212: recipe for target 'libsass-static' failed
    make: *** [libsass-static] Error 2
    nizzok@nizzok-ThinkPad-X201:~/sassc$ sudo make
    make BUILD="static" -C /home/nizzok
    make[1]: Entering directory '/home/nizzok'
    make[1]: *** No targets specified and no makefile found.  Stop.
    make[1]: Leaving directory '/home/nizzok'
    Makefile:212: recipe for target 'libsass-static' failed
    make: *** [libsass-static] Error 2
    

    So, are there more to date instructions? or any idea what's causing these errors?

  • Greg K
    Greg K almost 7 years
    Note the sassc build instructions prescribe a different layout. I couldn't get sassc to compile with make until I used their layout with sassc and sass-spec cloned as subdirs into the libsass directory (e.g. libsass/sassc, libsass/sass-spec.