'El Capitan的'无根打破旧的咕噜配置? [英] Is 'El Capitan's' rootless breaking old grunt configs?

查看:173
本文介绍了'El Capitan的'无根打破旧的咕噜配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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

  grunt --force 

示例Gruntfile.js文件内容:

$ $ p $ module.exports = function(grunt){

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

concat:{
//连接文件的配置在这里。
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:{
files:[{
expand:true,
cwd:'../img/src/',
src:['** /*.{png,jpg,gif}'],
dest:'../img/pro/'
}]
}
},

指南针:{
dev:{
选项:{
sassDir:'../sass',
cssDir:'../css',
fontsDir:'../fonts',
imagesDir:'../img/',
images:'../img/',
javascriptsDir:'../js/pro ,
// environment:'development',
outputStyle:'compressed',
relativeAssets:true,
httpPath:'。',
}
} ,
},

观看:{
scripts:{
files:['../js/**/**.js'],
任务:['concat','uglify'],
选项:{
spawn:true,
},
},
images:{
文件:['../img/src/**.{png,jpg,gif}'],
任务:['imagemin'],
选项:{
spawn :true,
}
},
指南针:{
files:['../**/*.{scss,sass}'],
tasks :['compass:dev'],
}

},

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


}) ;

//我们告诉Grunt我们打算使用这个插件。
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-svgstore');

//当我们在终端输入grunt时告诉Grunt该做什么。
grunt.registerTask('default',['concat','uglify',/ *'imagemin',* /'compass','svgstore','watch']);

};

示例package.json文件内容:

 <$ c 
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错误如下:

 运行concat:dist(concat)任务
警告:无法写入../js/pro/global.js文件(错误代码:EPERM)。使用 - 强制,继续。

运行uglify:build(uglify)任务
警告:无法写入../js/pro/global.min.js文件(错误代码:EPERM)。使用 - 强制,继续。

运行compass:dev(指南针)任务
警告:命令失败:/ bin / sh:指示符:找不到命令。使用 - 强制,继续。
警告:您需要安装Ruby和Compass,并在您的系统PATH中执行此任务。更多信息:https://github.com/gruntjs/grunt-contrib-compass使用--force,继续。

运行svgstore:defaults(svgstore)任务
警告:无法写入../img/svg-defs.svg文件(错误代码:EPERM)。使用 - 强制,继续。

运行监视任务
等待...

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



在El Capitan Betas期间,一些用户建议通过终端启用root - 虽然这似乎不再因为错误依然存在,并且/ usr / bin文件夹仍然不允许修改权限。

解决方案

同样的问题,我不得不使用安装到路径中的二进制文件:/ usr / bin,并在更新路径/ usr / local / bin后重新安装。 Ruby往往是主要的罪魁祸首。因为我在查找所有ruby安装时遇到困难,所以我最终安装了rbenv来管理我的ruby版本。



以下终端命令可能有助于识别有问题的路径:

 其中ruby 
gem environment
gem卸载[在此处插入宝石名称]
[google如何将路径设置为/ usr / local / bin ...(将在隐藏文件中)]
gem install [在此处插入gem名称]


After migrating to El Capitan, it seems users are experiencing an issue with grunt installations, possibly related to the rootless changes of El Capitan. In particular, running the grunt --force command results in EPERM errors. The workflow is as follows:

Assuming npm has been installed, navigate to the grunt directory with package.json and gruntfile.js and invoke grunt:

grunt --force

Example Gruntfile.js file contents:

module.exports = function(grunt) {

    // All configuration goes here 
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        concat: {
            // Configuration for concatenating files goes here.
            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: {
                files: [{
                    expand: true,
                    cwd: '../img/src/',
                    src: ['**/*.{png,jpg,gif}'],
                    dest: '../img/pro/'
                }]
            }
        },

        compass: {
            dev: {
                options: {              
                    sassDir: '../sass',
                    cssDir: '../css',
                    fontsDir: '../fonts',
                    imagesDir: '../img/',
                    images: '../img/',
                    javascriptsDir: '../js/pro',
                    //environment: 'development',
                    outputStyle: 'compressed',
                    relativeAssets: true,
                    httpPath: '.',
                }
            },
        },

        watch: {
            scripts: {
                files: ['../js/**/**.js'],
                tasks: ['concat', 'uglify'],
                options: {
                    spawn: true,
                },
            },
            images: {
                files: ['../img/src/**.{png,jpg,gif}'],
                tasks: ['imagemin'],
                options: {
                    spawn: true,
                }
            },
            compass: {
                files: ['../**/*.{scss,sass}'],
                tasks: ['compass:dev'],
            }

        },

        svgstore: {
            defaults: {
                options: {
                    prefix : 'icon-',
                },
                files: {
                    '../img/svg-defs.svg': ['../img/svg/*.svg']
                }
            }
        },


    });

    // Where we tell Grunt we plan to use this plug-in.
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-imagemin');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-compass');
    grunt.loadNpmTasks('grunt-svgstore');

    // Where we tell Grunt what to do when we type "grunt" into the terminal.
    grunt.registerTask('default', ['concat', 'uglify', /*'imagemin',*/ 'compass', 'svgstore', 'watch']);

};

Example package.json file contents:

{
"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"
  }
}

The resulting EPERM errors are as follows:

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...

Interestingly, Ruby and Compass are also installed, so it does align with the theory of the rootless unable to write to folders issues, but how can the dependency cores be moved elsewhere (i.e. /usr/local/bin) so this isn't an issue?

During the El Capitan Betas, some users suggested enabling root via terminal - though this seemingly no longer works, as the error persists and /usr/bin folder still doesn't allow for permission changes.

解决方案

For those running into the same issue, I had to eliminate the use of binaries installed to the path: /usr/bin, and reinstall after updating the path /usr/local/bin. Ruby tended to be the primary culprit. Because I was struggling with locating all my ruby installs, I ended up installing rbenv to manage my ruby versions.

The following terminal commands may be helpful in identifying your problematic paths:

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]

这篇关于'El Capitan的'无根打破旧的咕噜配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆