0

I'm pretty sure I've tracked the issue down to Node.js not seeing Sass, but I have no clue why...

If I push from my laptop using: git push lamp somebranch:master, the server remotely checks it out fine, runs npm install without error, and starts processing the gruntfile, but then aborts with "remote: Warning: spawn ENOENT Use --force to continue."

However, (after I push from my laptop like above) I can ssh in, cd into my hooks directory and run ./post-receive and it finishes "Done, without errors." I also tried running grunt in the website's root and it also completed without error.

Any ideas as to what might be going on? I'm completely stumped. Should I set paths to the sass gem in the hook? I scrapped down my gruntfile to use the same target locally as well as on the server to rule out the gruntfile. It compiles fine locally, compiles fine on the server, but fails only when using git push lamp somebranch:master.

  • Ok, I have some solid info. I added `grunt --verbose --debug` to my hook and it is failing on `sass sass/main.scss css/main.css` when pushing to the server. From the server it finds sass and executes. – Brian Chandler May 02 '15 at 16:50
  • Ugh. I've tracked it down to issues with the path, most likely (surprise, surprise...) my Ruby setup. I got the original error to change by adding to the PATH from .bashrc. Now I get a Gem::LoadError stating that it can't find sass. When pushing, the gem path has: `/home/(username)/.gem/ruby/2.2.0:/home/(username)/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0` in the newer error. Logged in and working, gem path is: `/home/(username)/.rvm/gems/ruby-2.2.1` and `/home/(username)/.rvm/gems/ruby-2.2.1@global` Is there not an easy way to set paths with Ruby for non-interactive shells? – Brian Chandler May 02 '15 at 20:13

1 Answers1

0

Some may wonder why I just didn't compile locally and dump the css into the web root from the devel box... perhaps I should. This time though, I really wanted Push-to-deploy all the way through, compiles and all. For anyone attempting the same thing and running into the same problem, this should help.

First off, it probably wouldn't hurt to scrub the system of any versions of ruby and sass that were installed via the distro's package manager. Then I scrubbed any remnants of previous tinkering with rvm implode and removed traces from .bashrc, etc. Next I ran \curl -sSL https://get.rvm.io | bash -s stable --ruby --auto-dotfiles and pressed ctrl-c to fix any errors first. Once the install script was happy, I let it download and install as normal. I did not have to use rvm install n.n.n,rvm use n.n.n, or rvm use n.n.n --default as 2.2.1 was pulled in like I wanted anyway and seemed fine. After rvm had setup ruby, I then ran gem install sass

Now, the end-all-be-all... using PermitUserEnvironment, like had been mentioned here: How to use sshd-config permituserenvironment option was the way to go. I saw that there were security concerns with that method, but it was the only thing that worked and I won't be trying to run limited shells. It is normal behavior for SSH to not allow the env vars when not using a login shell. I assumed, however, that the git hooks had full access to the user's normal vars (with ruby paths, etc.) and that assumption was incorrect. Add PermitUserEnvironment yes to the server's /etc/ssh/sshd_config or the like and restart the ssh daemon. As the user on the server, I ran env and copied that into .ssh/environment and cleaned up what wasn't needed. After that, I did my git push from the devel box and it found and ran the sass compiler just fine.

Community
  • 1
  • 1