Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less variables not imported globaly #426

Open
jmeyo opened this issue May 20, 2013 · 12 comments
Open

Less variables not imported globaly #426

jmeyo opened this issue May 20, 2013 · 12 comments

Comments

@jmeyo
Copy link

jmeyo commented May 20, 2013

Currently using the https://github.com/phiamo/symfony-bootstrap, and out of the box, assetic works perfectly but when we update the dependencies, the generated less file throw a 500 exception.

The main differences seems to be the upgrade on this assetic framework, can't figure out if it's related to the symfony assetic bundle.

Initial Git file

                "branch-alias": {
                    "dev-master": "1.1-dev"
                }.

Updated Git file

                "branch-alias": {
                    "dev-master": "1.2-dev"
                }.

Stack trace of the exception when loading the file through dev environment
http://somehost/app_dev.php/css/f1e3c9a_mopabootstrapsandboxbundle_1.css

/*
[exception] 500 | Internal Server Error | Assetic\Exception\FilterException
[message] An error occurred while running:
'/usr/bin/node' '/tmp/assetic_lessDI7bGF'

Error Output:
NameError: variable @inputHeight is undefined in mixins.less:157:14
156   width: 100%;
157   min-height: @inputHeight; // Make inputs at least the height of their button counterpart (base line-height + padding + border)
158   .box-sizing(border-box); // Makes inputs behave like true block-level elements



Input:
//
// Mixins

[truncated}
@cvschaefer
Copy link

I can confirm this issue. Twitter bootstrap defines all variables in an separate file "variables.less". After importing they should be available in global scope for reuse. The latest Less refactorings broke the previous correct behavior.

@vxf
Copy link

vxf commented Jun 2, 2013

following this

@cvschaefer
Copy link

Looks like applying the less filter based on file extension causes these issues.
Couldn't figure out exactly whats going on, but I guess after the latest code changes assetic started to apply the file extension based less filter even on "less internal" imports, leading to separate processing of these files.

A temporary solution for Symfony2 users is to remove the apply_to: ".less$" line in your config.yml and instead add the filter to the twig stylesheet tag.
Or just downgrade you assetic to an older version "kriswallsmith/assetic": "v1.1.0-alpha4" until this is resolved.

See also https://github.com/symfony/AsseticBundle/issues/198

@vxf
Copy link

vxf commented Jun 2, 2013

cvschaefer one interesting workaround I just got, was simply to disable cssembed and the less is parsed well, still don't know what's going on

@kriswallsmith
Copy link
Owner

I'm not sure how this is happening. Are you running both the Sass and CssEmbed filters?

@itn3rd77
Copy link

I can confirm this issue. Here is my compoiser.json and the relevant part from my config.yml:

composer.json

{
    "name": "symfony/framework-standard-edition",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": {
            "": "src/",
            "Eve\\Api": "vendor/localhome/"
         }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.3.*",
        "doctrine/orm": ">=2.2.3,<2.4-dev",
        "doctrine/doctrine-bundle": "dev-master",
        "twig/extensions": "dev-master",
        "symfony/assetic-bundle": "2.3.*",
        "symfony/swiftmailer-bundle": "2.3.*",
        "symfony/monolog-bundle": "2.3.*",
        "sensio/distribution-bundle": "2.3.*",
        "sensio/framework-extra-bundle": "2.3.*",
        "sensio/generator-bundle": "2.3.*",
        "jms/security-extra-bundle": "dev-master",
        "jms/di-extra-bundle": "dev-master",
        "jms/i18n-routing-bundle": "dev-master",
        "gregwar/image-bundle": "dev-master",
        "knplabs/knp-menu": "dev-master",
        "knplabs/knp-menu-bundle": "2.0.x-dev",
        "knplabs/knp-paginator-bundle": "dev-master",
        "kriswallsmith/assetic": "1.1.x-dev", 
        "saad-tazi/g-chart-bundle": "dev-master",
        "mopa/bootstrap-bundle": "dev-master",
        "mopa/bootstrap-sandbox-bundle": "dev-master",
        "mopa/composer-bridge": "dev-master",
        "twitter/bootstrap": "dev-master",
        "liip/theme-bundle": "dev-master",
        "craue/formflow-bundle": "dev-master",
        "pimple/pimple": "dev-master",
        "ezyang/htmlpurifier": "dev-master",
        "desarrolla2/rss-client-bundle": "dev-master",
        "desarrolla2/rss-client": "2.*",
        "desarrolla2/cache": "dev-master"
    },
    "repositories": [
        {
            "type": "package",
            "package": {
                "version": "master",
                "name": "twitter/bootstrap",
                "source": {
                    "url": "https://github.com/twitter/bootstrap.git",
                    "type": "git",
                    "reference": "master"
                },
                "dist": {
                    "url": "https://github.com/twitter/bootstrap/zipball/master",
                    "type": "zip"
                }
            }
        }
    ],
    "scripts": {
        "post-install-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"
        ],
        "post-update-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"
        ]
    },
    "minimum-stability": "stable",
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web"
    }
}

config.yml

...
# Assetic Configuration
assetic:
    debug:   %kernel.debug%
    use_controller: false
    filters:
        less:
            node: /usr/bin/nodejs
            node_paths: [/usr/lib/nodejs]
            apply_to: "\.less$"
        cssrewrite: ~
        cssembed:
            jar: %kernel.root_dir%/Resources/java/cssembed-0.4.5.jar
            apply_to: "\.css$|\.less$"
            max_uri_length: 524288
        yui_css:
            jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
            apply_to: "\.css$"
        yui_js:
            jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar        

...

@bobey
Copy link

bobey commented Jul 14, 2013

I have the exact same issue and disabling cssembed worked for me too...

@bmeynell
Copy link

Same issue here

1 similar comment
@JHernan
Copy link

JHernan commented Dec 26, 2013

Same issue here

@soullivaneuh
Copy link

Any news about this issue? How to solve it?

@althaus
Copy link

althaus commented May 24, 2016

Still an issue. Did anybody solve this?

We're still using Assetic. As it's dropped by Symfony 3.0 it seems to be time to move along: 😞

@Defcon0
Copy link

Defcon0 commented Aug 16, 2016

confirmed for symfony 2.8. Why isn't that one fixed? It's major :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests