1

I'm trying to get SASS to watch an SCSS file for changes. When I run the watch command in any desktop folder, it works e.g. sass --watch Documents/test.scss:Documents/test.css.

But when I run it in the /var/www directory, it fails. For example, running sass --watch /var/www/scss/test.scss:/var/www/css/test.css" results in the following error: Errno::EACCES: Permission denied - /var/www/css/test.css. That is likely because the /var/www directory is owned by Apache.

I tried using sudo sass --watch /var/www/test.scss:/var/www/test.css command to run the command as root, but that gives me the follow error: sudo: sass: command not found.

I'm running this on Ubuntu 12.10 with Ruby 1.9.3. I'm fairly new to both.

Khanjan Desai
  • 90
  • 2
  • 11

2 Answers2

2

Your sass binary must be in a location not in root's $PATH. Find where it's located, as your own user:

which sass

Then use that full path to the sass binary in your sudo command.

Patrice Levesque
  • 2,079
  • 17
  • 16
  • I tried what you suggested with the following command `sudo /home/user/.rvm/gems/ruby-1.9.3-p429/bin/sass --watch /var/www/test.scss:/var/www/test.css`, but that gave me the following error: `/usr/bin/env: ruby_noexec_wrapper: No such file or directory`. I looked through [this](http://stackoverflow.com/questions/12127603/usr-bin-env-ruby-noexec-wrapper-fails-with-no-file-or-directory), but that didn't really help. Thanks for the help. – Khanjan Desai May 26 '13 at 05:44
  • Then it seems your `sass` command behaviour is tied to your user. I suggest you add yourself to apache's group, so that you can write to its directories. Make sure the /var/www directory is apache group-writable (and it would be good as well to setgid that directory; would automagically set your files created on your user behalf to the apache group). – Patrice Levesque May 26 '13 at 05:52
2

You probably installed rvm as an user. If you run a command with sudo, you are running it as the user root, where rvm and the whole ruby environment is not installed.

To solve this problem, you can use rvmsudo (see http://ruby.about.com/od/rubyversionmanager/qt/Rvm-And-Sudo.htm)

iblue
  • 29,609
  • 19
  • 89
  • 128