El Capitan的“无根打破旧的咕噜configuration?

在迁移到El Capitan后,似乎用户正在经历一个咕噜安装的问题,可能与El Capitan的根本性变化有关。 特别是,运行grunt –force命令会导致EPERM错误。 工作stream程如下:

假设已安装npm,请使用package.json和gruntfile.js导航到grunt目录并调用grunt:

grunt --force 

示例Gruntfile.js文件内容:

  module.exports = function(grunt){

     //所有configuration都在这里 
     grunt.initConfig({
         pkg:grunt.file.readJSON('package.json'),

         concat:{
             //连接文件的configuration在这里。
             dist:{
                 src:[
                         ” ../js/libs/owl.carousel.js',
                         ” ../js/libs/jquery.actual.js',
                         ” ../js/libs/chosen.jquery.js',
                         ” ../js/libs/jquery.parallax.js',
                         ” ../js/src/common.js'  
                 ]
                 dest:'../js/pro/global.js',
             },
         },

         uglify:{
            build立:{
                 src:'../js/pro/global.js',
                 dest:'../js/pro/global.min.js',
             },
         },


         imagemin:{
            dynamic:{
                文件:[{
                    展开:true,
                     cwd:'../img/src/',
                     src:['** / *。{png,jpg,gif}'],
                     dest:'../img/pro/'
                 }]
             }
         },

        指南针:{
             dev:{
                选项:{              
                     sassDir:'../sass',
                     cssDir:'../css',
                     fontsDir:'../fonts',
                     imagesDir:'../img/',
                    图片:'../img/',
                     javascriptsDir:'../js/pro',
                     //环境:“发展”,
                     outputStyle:'compressed',
                     relativeAssets:true,
                     httpPath:'。',
                 }
             },
         },

        看:{
            脚本:{
                文件:['../js/**/**.js'],
                任务:['concat','uglify'],
                选项:{
                    产卵:真,
                 },
             },
            图片: {
                文件:['../img/src/**.{png,jpg,gif}'],
                任务:['imagemin'],
                选项:{
                    产卵:真,
                 }
             },
            指南针:{
                文件:['../**/*.{scss,sass}'],
                任务:['compass:dev'],
             }

         },

         svgstore:{
            默认值:{
                选项:{
                    前缀:'icon-',
                 },
                文件:{
                     '../img/svg-defs.svg':['../img/svg/*.svg']
                 }
             }
         },


     });

     //我们在哪里告诉Grunt,我们打算使用这个插件。
     grunt.loadNpmTasks( '咕噜-的contrib-的concat');
     grunt.loadNpmTasks( '咕噜-的contrib-丑化');
     grunt.loadNpmTasks( '咕噜-的contrib-imagemin');
     grunt.loadNpmTasks( '咕噜-的contrib手表');
     grunt.loadNpmTasks( '咕噜-的contrib罗盘');
     grunt.loadNpmTasks( '咕噜-svgstore');

     //当我们在terminalinput“grunt”时,告诉Grunt该怎么做。
     grunt.registerTask('default',['concat','uglify',/ *'imagemin',* /'compass','svgstore','watch']);

 };

示例package.json文件内容:

 { "name": "Call Me Maybe", "version": "0.2.0", "devDependencies": { "grunt": "^0.4.5", "grunt-contrib-compass": "^1.0.4", "grunt-contrib-concat": "^0.5.1", "grunt-contrib-imagemin": "^0.9.4", "grunt-contrib-sass": "^0.9.2", "grunt-contrib-uglify": "^0.9.2", "grunt-contrib-watch": "^0.6.1", "grunt-svgstore": "^0.5.0" } } 

由此产生的EPERM错误如下所示:

 Running "concat:dist" (concat) task Warning: Unable to write "../js/pro/global.js" file (Error code: EPERM). Used --force, continuing. Running "uglify:build" (uglify) task Warning: Unable to write "../js/pro/global.min.js" file (Error code: EPERM). Used --force, continuing. Running "compass:dev" (compass) task Warning: Command failed: /bin/sh: compass: command not found. Used --force, continuing. Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Used --force, continuing. Running "svgstore:defaults" (svgstore) task Warning: Unable to write "../img/svg-defs.svg" file (Error code: EPERM). Used --force, continuing. Running "watch" task Waiting... 

有趣的是,Ruby和Compass也被安装,所以它确实符合无根的理论,无法写入文件夹问题, 但依赖核心如何移动到别处 (即/ usr / local / bin), 所以这不是问题?

在El Capitan Betas期间,一些用户build议通过terminal启用root,尽pipe这看起来不再有效,因为错误依然存在,而/ usr / bin文件夹仍然不允许更改权限。

对于遇到同样问题的用户,我不得不使用安装到path/ usr / bin的二进制文件,并在更新path/ usr / local / bin后重新安装。 ruby往往是主要的罪魁祸首。 因为我正在努力寻找所有的ruby安装,所以我最终安装了rbenv来pipe理我的ruby版本。

以下terminal命令可能有助于识别有问题的path:

 which ruby gem environment gem uninstall [insert gem name here] [google how to set your paths to /usr/local/bin... (will be in a hidden file)] gem install [insert gem name here] 

在/ usr / bin上安装非系统软件是一个坏的举动,现在在El Capitan是禁止的,并且有很好的理由。

我不熟悉grunt,但是如果你可以使用/ usr / local / bin,那么可能一切正常。