简体   繁体   English

在Rails作曲家自定义配方中从回购中克隆时,Thor empty_directory命令会引发“权限被拒绝”

[英]Thor empty_directory command raises 'permission denied' when cloning from repo in rails composer custom recipe

Today I'm fighting against this: 今天,我正在与这个斗争:

mkdir': Permission denied @ dir_s_mkdir - /app/assets/stylesheets/material_ui (Errno::EACCES)

I'm creating my own rails composer generator. 我正在创建自己的Rails作曲器生成器。 What I want is clone from my repo some files and put them inside the app I'm generating when I call rails new etc etc... . 我想要的是从我的仓库中克隆一些文件,并将它们放入我将其称为rails new etc etc...时正在生成的应用程序中。 The generator works well (it clones a lot of files, it even unzips a big font folder!) and all the recipes do their work except one. 该生成器运行良好(它克隆了许多文件,甚至解压缩了一个大字体文件夹!),除一个之外,所有食谱都可以正常工作。

This one contains (among others) this line 此行(除其他外)包含此行

empty_directory '/app/assets/stylesheets/material_ui'

This Thor action fails saying 'permission denied'. 雷神(Thor)行动失败,说“权限被拒绝”。

Of course I cannot CHMOD anything before, because there is not any folder until I launch the rails new command. 当然,我以前不能更改任何内容,因为在启动rails new命令之前没有任何文件夹。

How can I create a directory in a rails composer recipe using Thor? 如何使用Thor在Rails作曲家的菜谱中创建目录?

Perhaps the directory does not exist. 该目录可能不存在。 Remember the difference between: 记住以下两者之间的区别:

empty_directory 'app/assets/stylesheets/material_ui'
empty directory '/app/assets/stylesheets/material_ui'

I have found the solution. 我找到了解决方案。 Is so simply to be silly, but as I've found other people stumbling against this mistake, I'll answer my own question as documentation. 简直就是愚蠢,但是当我发现其他人为这个错误而绊脚石时,我将以文档的形式回答我自己的问题。

The fail is in the path. 失败就在眼前。

empty_directory '/app/assets/stylesheets/material_ui'

is not the same of 与...不同

empty_directory 'app/assets/stylesheets/material_ui'

The second one is the right one because is the absolute path , of the generated application. 第二个是正确的,因为它是生成的应用程序的绝对路径

The first one, as it starts with / is interpreted as a subfolder of the recipe execution point, and, as it doesn't exists, it raises a permission error. 第一个以/开头,被解释为配方执行点的子文件夹,并且由于不存在,因此引发权限错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM