diff --git a/slapos/recipe/wrapper.py b/slapos/recipe/wrapper.py
index 6f2f0d800ecb48ac2103c44b1893fd22c21e83c1..cb0f1c266fbfde42072fae2a7efe89dc946b5756 100644
--- a/slapos/recipe/wrapper.py
+++ b/slapos/recipe/wrapper.py
@@ -53,9 +53,7 @@ class Recipe(GenericBaseRecipe):
                           if filename.strip()]
         if environment is not None:
             environment = dict((k.strip(), v.strip()) for k, v in [
-                             line.split('=')
-                             for line in environment.split('\n')
-                           ])
+              line.split('=') for line in environment.splitlines() if line.strip() ])
         return [self.createPythonScript(
             wrapper_path,
             'slapos.recipe.librecipe.execute.generic_exec',