[2.1.0 java] Play 2.0 with SASS on Heroku

1,078 views
Skip to first unread message

nand...@gmail.com

unread,
Feb 28, 2013, 5:07:09 PM2/28/13
to play-fr...@googlegroups.com
Has anyone deployed a Play 2.0 application with SASS stylesheets to Heroku?


I'm using play-sass to compile the .scss files at build time, but it fails when running on Heroku because sass is not installed.
Cannot run program "sass": error=2, No such file or directory

I've managed to install SASS using the heroku-buildpack-ruby (with  heroku-buildpack-multi to call it and then buildpack-scala), but it is not working.
If i execute  sass -v  i get a LoadError:

<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- bundler/setup (LoadError)

from <internal:lib/rubygems/custom_require>:29:in `require'


It seems i'll have to install Bundler as part of the scala buildpack, as ruby's does, to make the gems available to sass.


I'm a complete noob to sbt, play and heroku. So i may be missing something pretty easy...
If anyone has a better idea, i'm all ears!

I'll keep you posted if it ever works!

Thanks!

Marius Soutier

unread,
Feb 28, 2013, 5:40:54 PM2/28/13
to play-fr...@googlegroups.com
You can't use bundler because then Heroku thinks you're deploying a Ruby app. You have to include the SASS source code, and create a ruby script called "sass" to launch it.
> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

nand...@gmail.com

unread,
Feb 28, 2013, 6:35:08 PM2/28/13
to play-fr...@googlegroups.com
I've managed to bypass this by explicitly stating the buildpack to use (using the BUILDPACK_URL).
I've made it run the Ruby one first, and then the Scala (for Play 2) with a custom buildpack-multi.

But it seems that using the buildpack approach i would have to create a custom Ruby buildpack to install and configure SASS and add it to the PATH so that play-sass can use it.

What do you mean by including SASS source code?
Is it adding it to my own repository (the one i'm pushing to heroku)?

I'll try creating the "sass" ruby script to use SASS from source, without installing it.

Marius Soutier

unread,
Mar 1, 2013, 3:37:50 AM3/1/13
to play-fr...@googlegroups.com
> But it seems that using the buildpack approach i would have to create a custom Ruby buildpack to install and configure SASS and add it to the PATH so that play-sass can use it.

I had the problem that these buildpacks would destroy each other's heroku config.


> What do you mean by including SASS source code?
> Is it adding it to my own repository (the one i'm pushing to heroku)?

Yes exactly, you can get SASS from https://github.com/nex3/sass or extract it from your local installation. I just put the entire folder in my project and then copied and adapted the "sass" script:

#!/usr/bin/env ruby
# The command line Sass parser.

require File.dirname(__FILE__) + '/sass-3.1.19/lib/sass'
require 'sass/exec'

opts = Sass::Exec::Sass.new(ARGV)
opts.parse!

nand...@gmail.com

unread,
Mar 7, 2013, 3:42:38 PM3/7/13
to play-fr...@googlegroups.com
Here is what i ended up with:

Using heroku-buildpack-multi to invoke two buildpacks:
  1. heroku-buildpack-ruby to install Bundler and the required gems (sass and compass in my case).
  2. heroku-buildpack-scala to deploy the Play! 2.1 application
I forked the Multi buildpack to debug the environment and ended up using it to add a few environment variables after running the Ruby buildpack:
export PATH="/tmp/bin:bin:vendor/bundle/ruby/1.9.1/bin:$PATH"
export GEM_PATH="vendor/bundle/ruby/1.9.1"
export GEM_HOME="$GEM_PATH"
export BUNDLE_GEMFILE="$1/Gemfile"
export BUNDLE_CONFIG="$1/.bundle/config"

But i believe the same can be achieved using heroku config:add .
Just need to check if the last two can be relative.


Anyway, i think i'll switch to deploying only the binaries (play dist).
Last week Heroku was really slow, causing the deployment to fail every time (timed out after 10 min).
It would spend most of the time downloading core sbt dependencies.
Sometimes it would not even start compiling...


Currently these seem to be the only options for using play-sass on Heroku.
You either add SASS to your repository as Marius suggested, or mess with buildpacks.

Hope someone finds out something easier! I'd love a fully java sass compiler!


Thanks for the help!

Mariusz Zieliński

unread,
Mar 17, 2013, 8:57:12 PM3/17/13
to play-fr...@googlegroups.com
Hey, could you help me little with this? I'm trying to deploy on Heroku, I've put sass-stable from git in my projects folder and created 'sass' file in my projects folder with content:

#!/usr/bin/env ruby 
# The command line Sass parser. 

require File.dirname(__FILE__) + '/sass-stable/lib/sass' 
require 'sass/exec' 

opts = Sass::Exec::Sass.new(ARGV) 
opts.parse!

Though after trying to deploy I get message:

java.io.IOException: Cannot run program "sass": java.io.IOException: error=13, Permission denied

Thanks in advance

James Ward

unread,
Mar 17, 2013, 8:59:03 PM3/17/13
to play-fr...@googlegroups.com
It looks like the file is not executable.

-James


From: Mariusz Zieli ski <evil...@gmail.com>
Date: Sun, 17 Mar 2013 17:57:12 -0700 (PDT)
Subject: [play-framework] Re: [2.1.0 java] Play 2.0 with SASS on Heroku

Mariusz Zieliński

unread,
Mar 17, 2013, 9:02:33 PM3/17/13
to play-fr...@googlegroups.com, james...@typesafe.com
The problem is I'm working from Windows machine so it's hard to say if it's executable :-) At least when i'm looking at it from msys it seems to have +x on it.

Mariusz Zieliński

unread,
Mar 17, 2013, 9:15:13 PM3/17/13
to play-fr...@googlegroups.com
Ok, I've managed to run it. Just for anyone with similiar problem:

git update-index --chmod=+x

should help

Vladimir Okhotnikov

unread,
Apr 13, 2013, 4:42:58 PM4/13/13
to play-fr...@googlegroups.com
Just FYI, I ended up with arguably a bit simpler solution: I forked the heroku-buildpack-scala and added the following 4 lines into compile script:

mkdir -p $CACHE_DIR/.gems
gem install -i $CACHE_DIR/.gems --no-rdoc compass
export PATH=$PATH:$CACHE_DIR/.gems/bin
export GEM_PATH=$GEM_PATH:$CACHE_DIR/.gems

right after  mkdir -p $CACHE_DIR

Then referenced my buildpack fork via heroku config:set

It worked like a charm, at least for a test project that I was messing with.

opyate

unread,
Apr 28, 2014, 5:10:03 AM4/28/14
to play-fr...@googlegroups.com
On Saturday, April 13, 2013 9:42:58 PM UTC+1, Vladimir Okhotnikov wrote:
Just FYI, I ended up with arguably a bit simpler solution: I forked the heroku-buildpack-scala and added the following 4 lines into compile script:


Please paste a link here to your repo.
 

Felix Dietze

unread,
Mar 11, 2015, 8:36:17 PM3/11/15
to play-fr...@googlegroups.com
This works for me:
$ heroku config:set BUILDPACK_URL=https://github.com/fdietze/heroku-buildpack-scala

 

Joe Kutner

unread,
Mar 12, 2015, 2:36:27 PM3/12/15
to play-fr...@googlegroups.com
I should point out that Heroku's multi-buildpack will work in this case now (the Ruby buildpack passes the gems along to the Scala buildpack). In fact, here's an Play template that uses sass, compass, grunt, bower and more:
https://github.com/mohiva/play-silhouette-angular-seed
Reply all
Reply to author
Forward
0 new messages