basset
basset copied to clipboard
LessFilter error
Hello,
I have done a fresh install of the latest nodejs (0.10.10), less (1.4.0), basset and laravel 4 on ubuntu. I have configured everything per documentation and set the node_modules path. I have tried everything and always get the same error message:
basset.ERROR: Failed to find required constructor argument for filter "LessFilter". (Parameter #0 [
Seems like the node_module path is not getting through?
Thanks!
What is the path to your Node installation? On 8 Jun 2013 02:36, "realsurfer" [email protected] wrote:
Hello,
I have done a fresh install of the latest nodejs (0.10.10), less (1.4.0), basset and laravel 4 on ubuntu. I have configured everything per documentation and set the node_modules path. I have tried everything and always get the same error message:
basset.ERROR: Failed to find required constructor argument for filter "LessFilter". (Parameter #0 [ $nodeBin = '/usr/bin/node' ]) [] []
Seems like the node_module path is not getting through?
Thanks!
— Reply to this email directly or view it on GitHubhttps://github.com/jasonlewis/basset/issues/154 .
Thanks for your quick reply!
In /usr/bin I have:
lrwxrwxrwx 1 root root 22 Jun 7 16:14 node -> /etc/alternatives/node -rwxr-xr-x 1 root root 8298352 Jun 5 07:37 nodejs
Are you using the Less
filter alias? If so, you might need to drop findMissingConstructorArgs
and manually add the node paths.
Note that I just pushed a change that allows you to call getNodePaths
.
$filter->setArgument($filter->getNodePaths(), 1);
Use that instead, that should use the default /usr/bin/node
argument as the path to Node but add the array of node paths as the second argument.
I basically used the default config (see below). I added your code to the Less alias and updated basset to the latest and now get:
call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object
<?php
return array(
/*
|--------------------------------------------------------------------------
| Collections
|--------------------------------------------------------------------------
|
| Basset is built around collections. A collection contains assets for
| your application. Collections can contain both stylesheets and
| javascripts.
|
| A default "application" collection is ready for immediate use. It makes
| a couple of assumptions about your directory structure.
|
| /public
| /assets
| /stylesheets
| /less
| /sass
| /javascripts
| /coffeescripts
|
| You can overwrite this collection or remove it by publishing the config.
|
*/
'collections' => array(
'application' => function($collection)
{
// Switch to the stylesheets directory and require the "less" and "sass" directories.
// These directories both have a filter applied to them so that the built
// collection will contain valid CSS.
$directory = $collection->directory('assets/css', function($collection)
{
$collection->requireDirectory('less')->apply('Less');
$collection->requireDirectory('less/bootstrap')->apply('Less');
//$collection->requireDirectory('sass')->apply('Sass');
$collection->requireDirectory();
});
$directory->apply('CssMin');
$directory->apply('UriRewriteFilter');
// Switch to the javascripts directory and require the "coffeescript" directory. As
// with the above directories we'll apply the CoffeeScript filter to the directory
// so the built collection contains valid JS.
$directory = $collection->directory('assets/js', function($collection)
{
//$collection->requireDirectory('coffeescripts')->apply('CoffeeScript');
$collection->requireDirectory('bootstrap');
$collection->requireDirectory();
});
$directory->apply('JsMin');
}
),
/*
|--------------------------------------------------------------------------
| Production Environment
|--------------------------------------------------------------------------
|
| Basset needs to know what your production environment is so that it can
| respond with the correct assets. When in production Basset will attempt
| to return any built collections. If a collection has not been built
| Basset will dynamically route to each asset in the collection and apply
| the filters.
|
| The last method can be very taxing so it's highly recommended that
| collections are built when deploying to a production environment.
|
| You can supply an array of production environment names if you need to.
|
*/
'production' => array('prod'),
/*
|--------------------------------------------------------------------------
| Build Path
|--------------------------------------------------------------------------
|
| When assets are built with Artisan they will be stored within a directory
| relative to the public directory.
|
| If the directory does not exist Basset will attempt to create it.
|
*/
'build_path' => 'cache',
/*
|--------------------------------------------------------------------------
| Debug
|--------------------------------------------------------------------------
|
| Enable debugging to have potential errors or problems encountered
| during operation logged to a rotating file setup.
|
*/
'debug' => true,
/*
|--------------------------------------------------------------------------
| Node Paths
|--------------------------------------------------------------------------
|
| Many filters use Node to build assets. We recommend you install your
| Node modules locally at the root of your application, however you can
| specify additional paths to your modules.
|
*/
'node_paths' => array(
//base_path().'/../../node_modules'
'/var/www/node_modules'
),
/*
|--------------------------------------------------------------------------
| Gzip Built Collections
|--------------------------------------------------------------------------
|
| To get the most speed and compression out of Basset you can enable Gzip
| for every collection that is built via the command line. This is applied
| to both collection builds and development builds.
|
| You can use the --gzip switch for on-the-fly Gzipping of collections.
|
*/
'gzip' => false,
/*
|--------------------------------------------------------------------------
| Asset and Filter Aliases
|--------------------------------------------------------------------------
|
| You can define aliases for commonly used assets or filters.
| An example of an asset alias:
|
| 'layout' => 'stylesheets/layout/master.css'
|
| Filter aliases are slightly different. You can define a simple alias
| similar to an asset alias.
|
| 'YuiCss' => 'Yui\CssCompressorFilter'
|
| However if you want to pass in options to an aliased filter then define
| the alias as a nested array. The key should be the filter and the value
| should be a callback closure where you can set parameters for a filters
| constructor, etc.
|
| 'YuiCss' => array('Yui\CssCompressorFilter', function($filter)
| {
| $filter->setArguments('path/to/jar');
| })
|
|
*/
'aliases' => array(
'assets' => array(),
'filters' => array(
/*
|--------------------------------------------------------------------------
| Less Filter Alias
|--------------------------------------------------------------------------
|
| Filter is applied only when asset has a ".less" extension and it will
| attempt to find missing constructor arguments.
|
*/
'Less' => array('LessFilter', function($filter)
{
//$filter->whenAssetIs('.*\.less')->findMissingConstructorArgs();
$filter->setArgument($filter->getNodePaths(), 1);
}),
/*
|--------------------------------------------------------------------------
| Sass Filter Alias
|--------------------------------------------------------------------------
|
| Filter is applied only when asset has a ".sass" or ".scss" extension and
| it will attempt to find missing constructor arguments.
|
*/
'Sass' => array('Sass\ScssFilter', function($filter)
{
$filter->whenAssetIs('.*\.(sass|scss)')->findMissingConstructorArgs();
}),
/*
|--------------------------------------------------------------------------
| CoffeeScript Filter Alias
|--------------------------------------------------------------------------
|
| Filter is applied only when asset has a ".coffee" extension and it will
| attempt to find missing constructor arguments.
|
*/
'CoffeeScript' => array('CoffeeScriptFilter', function($filter)
{
$filter->whenAssetIs('.*\.coffee')->findMissingConstructorArgs();
}),
/*
|--------------------------------------------------------------------------
| CssMin Filter Alias
|--------------------------------------------------------------------------
|
| Filter is applied only when within the production environment and when
| the "CssMin" class exists.
|
*/
'CssMin' => array('CssMinFilter', function($filter)
{
$filter->whenProductionBuild()->whenClassExists('CssMin');
}),
/*
|--------------------------------------------------------------------------
| JsMin Filter Alias
|--------------------------------------------------------------------------
|
| Filter is applied only when within the production environment and when
| the "JsMin" class exists.
|
*/
'JsMin' => array('JSMinFilter', function($filter)
{
$filter->whenProductionBuild()->whenClassExists('JSMin');
}),
/*
|--------------------------------------------------------------------------
| UriRewrite Filter Alias
|--------------------------------------------------------------------------
|
| Filter gets a default argument of the path to the public directory.
|
*/
'UriRewriteFilter' => array('UriRewriteFilter', function($filter)
{
$filter->setArguments(public_path());
})
)
)
);
Woops. It's late here. I forgot to commit and push. :tired_face:
Try updating again.
Ah yes:
ErrorException …/vendor/jasonlewis/basset/src/Basset/Filter/Filter.php:552
See above comment again. Sorry!
Updated and unfortunately get the same error.
Is the order correct? I might be off but in LessFilter.php it looks like this:
public function __construct($nodeBin = '/usr/bin/node', array $nodePaths = array())
I got a little further now. Your new function was getNodePath and not getNodePaths. Now I got a new error in "…/vendor/symfony/process/Symfony/Component/Process/ProcessUtils.php:58":
escapeshellarg() expects parameter 1 to be string, array given
Is this a bug with Assetic?
Just so that you know I am compiling the latest bootstrap 3 less files when I get this error.
I've been able to successfully get Bootstrap compiled on my Windows and CentOS machine. What OS are you using?
Ubuntu Server 12.04. Are you compiling bootstrap 3? I haven't tried the 2 branch.
Got it working now. There were no issues with the less files but with the basic configuration. I added the config below and then it worked:
'Less' => array('LessFilter', function($filter)
{
$filter->whenAssetIs('.*\.less')->setArguments('/usr/bin/node', array('/var/www/node_modules/'));
}),
Having a similar error over here with a new machine. I can run php artisan basset:build --production
and the assets compile correctly, but they don't compile automatically on the development environment (the files are cached and renamed to .css it seems, but they are not actually passed through the Less filter). On another machine, set up the same way, no problems...
For some reason, I'm now getting the same error on my primary machine. The Node.js installer for Mac places node
at usr/local/bin/node
.
I've tested the following filters:
$filter->whenAssetIs('.*\.less')->setArgument('/usr/local/bin/node', 1)->findMissingConstructorArgs();
And:
$filter->whenAssetIs('.*\.less')->setArguments('/usr/local/bin/node', array(base_path() . '/node_modiles'));
However, I'm now getting this error:
Symfony \ Component \ Process \ Exception \ RuntimeException
The process has been signaled with signal "5".
On another note, if I set the path to my Node in the LessFilter
constructor, it does actually work...
public function __construct($nodeBin = '/usr/local/bin/node', array $nodePaths = array())
{
...
}
I'm not sure why this works and setArgument('/usr/local/bin/node', 1)
doesn't...