ruby “Errno::EACCESS...权限被拒绝”运行指南针手表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22597223/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Errno::EACCESS...permission denied" running compass watch
提问by Sheixt
I just migrated my project files onto a new PC on the D:drive whilst my programs (Git, Node Js, Ruby, etc) are on the C:drive.
我只是将我的项目文件迁移到D:驱动器上的新 PC 上,而我的程序(Git、Node Js、Ruby 等)在C:驱动器上。
I have tried to run compass watchafter editing a SASS file, but encounter this error:
我曾尝试compass watch在编辑 SASS 文件后运行,但遇到此错误:
Errno::EACCES on line ["897"] of C: Permission denied - <D:/project_dir/stylesheets/app.css20140323-10532-gziux, D:/project_dir/stylesheets/app.css>
Run with --trace to see the full backtrace
I'm a novice with Ruby at the command line (as I only use it for web development purposes). What do I need to do to allow the permissions?
我是 Ruby 命令行的新手(因为我只将它用于 Web 开发目的)。我需要做什么才能允许权限?
Please let me know if I can provide more information.
如果我能提供更多信息,请告诉我。
EDIT:
Here's what was returned after running compass watch --trace:
编辑:这是运行后返回的内容compass watch --trace:
D:\project_dir>compass watch --trace
>>> Change detected at 21:53:53 to: app.scss
overwrite stylesheets/app.css
Errno::EACCES on line ["897"] of C: Permission denied - (D:/project_dir/stylesheets/app.css20140323-14712-11v62k7, D:/project_dir/stylesheets/app.css)
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/sass-3.2.18/lib/sass/util.rb:897:in `atomic_create_and_write_file'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/actions.rb:58:in `write_file'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/compiler.rb:143:in `compile'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/compiler.rb:118:in `compile_if_required'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/compiler.rb:103:in `block (2 levels) in run'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/compiler.rb:101:in `each'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/compiler.rb:101:in `block in run'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/compiler.rb:126:in `timed'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/compiler.rb:100:in `run'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/commands/watch_project.rb:147:in `recompile'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/commands/watch_project.rb:68:in `perform'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/commands/base.rb:18:in `execute'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/commands/project_base.rb:19:in `execute'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/exec/sub_command_ui.rb:43:in `perform!'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/lib/compass/exec/sub_command_ui.rb:15:in `run!'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/bin/compass:30:in `block in <top (required)>'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/bin/compass:44:in `call'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.4/bin/compass:44:in `<top (required)>'
C:/Ruby200-x64/bin/compass:23:in `load'
C:/Ruby200-x64/bin/compass:23:in `<main>'
>>> Compass is polling for changes. Press Ctrl-C to Stop.
I don't know what to make from that though.
我不知道该怎么做。
From doing some reading (https://github.com/chriseppstein/compass/issues/1406) I believe it's something to do with the permissions or PATH for 'Ruby' & 'Ruby Gems'but I don't know what to do to resolve this.
通过阅读(https://github.com/chriseppstein/compass/issues/1406),我相信这与“Ruby”和“Ruby Gems”的权限或路径有关,但我不知道该怎么做来解决这个问题。
回答by Bill Duncan
To get it to work in 32 or 64bit windows, I done what Min Ren suggested but I also had to manually clean the gem repository (C:\Users\myusername\.gem\specs\rubygems.org%443\quick\Marshal.4.8) of all the sass and compass gemspec files after the uninstall steps. I also installed sass before compass.
为了让它在 32 位或 64 位窗口中工作,我按照 Min Ren 的建议做了,但我还必须C:\Users\myusername\.gem\specs\rubygems.org%443\quick\Marshal.4.8在卸载步骤后手动清理所有 sass 和 compass gemspec 文件的 gem 存储库 ( )。我还在指南针之前安装了 sass。
gem uninstall compass
gem uninstall sass
manually clean .gem
手动清理 .gem
gem install sass --version "3.2.10"
gem install compass --version "0.12.2"
回答by Mark Hazlewood
I was having this same issue for a while and eventually fixed it manually. After some digging, the issue appears to be that in util.rb, the temp file is being renamed before the file is closed. In Windows, this apparently isn't permitted (although not sure why I suddenly started getting the problem after it had been working on the past).
我有一段时间遇到了同样的问题,最终手动修复了它。经过一番挖掘,问题似乎是在 util.rb 中,临时文件在文件关闭之前被重命名。在 Windows 中,这显然是不允许的(虽然不知道为什么我在过去工作后突然开始遇到问题)。
The fix for me was to edit util.rb (PATH_TO_RUBY\lib\ruby\gems\1.9.1\gems\sass-3.2.18\lib\sass\util.rb). I copied the line closing the temp file to before the permission change + rename on line 897. Here is the updated function as I now have it:
我的解决方法是编辑 util.rb (PATH_TO_RUBY\lib\ruby\gems\1.9.1\gems\sass-3.2.18\lib\sass\util.rb)。我将关闭临时文件的行复制到第 897 行的权限更改 + 重命名之前。这是我现在拥有的更新功能:
def atomic_create_and_write_file(filename, perms = 0666)
require 'tempfile'
tmpfile = Tempfile.new(File.basename(filename), File.dirname(filename))
tmpfile.binmode if tmpfile.respond_to?(:binmode)
result = yield tmpfile
tmpfile.flush # ensure all writes are flushed to the OS
begin
tmpfile.fsync # ensure all buffered data in the OS is sync'd to disk.
rescue NotImplementedError
# Not all OSes support fsync
end
tmpfile.close if tmpfile
# Make file readable and writeable to all but respect umask (usually 022).
File.chmod(perms & ~File.umask, tmpfile.path)
File.rename tmpfile.path, filename
result
ensure
# close and remove the tempfile if it still exists,
# presumably due to an error during write
tmpfile.close if tmpfile
tmpfile.unlink if tmpfile
end
One big caveat here is that I'm not a Ruby person and I'm sure there is probably a better way. But I just tried this mod quickly, and it worked, so I didn't put more into it.
这里的一个重要警告是,我不是 Ruby 人,而且我确信可能有更好的方法。但我只是快速尝试了这个 mod,它奏效了,所以我没有投入更多。
回答by Min Ren
It looks like a bug in the newest version of Sass.
它看起来像是最新版本的 Sass 中的一个错误。
Uninstalling Sass and Compass and installing the older versions fixes the issue.
卸载 Sass 和 Compass 并安装旧版本可修复该问题。
There might be newer versions that do work, but here's what I've tested and know works.
可能有更新的版本可以工作,但这是我测试过的并且知道有效的版本。
gem uninstall compass
gem uninstall sass
gem install compass -v "0.12.2"
gem install sass -v "3.2.13"
回答by grigson
Looks like issue is solved in SASS 3.2.19
看起来问题在 SASS 3.2.19 中解决了
so all you need is gem update compass
所以你只需要 gem update compass
回答by Wake
I was getting a similar error, but had a completely different resolution, so I thought it was worth sharing in case anyone else runs into my scenario.
我遇到了类似的错误,但有一个完全不同的解决方案,所以我认为值得分享,以防其他人遇到我的情况。
I was actually getting permission denied because my source control had made my .css files read-only. The solution was simple enough, just check out the css files and everything went back to normal.
我实际上被拒绝了,因为我的源代码管理使我的 .css 文件成为只读的。解决方法很简单,只要查看css文件,一切就恢复正常了。
回答by cizza
I had the same problem. I did the suggested - uninstall & install with the --pre, however that didn't solve my problem. I've run into another problems after that. Well, what I did then is: I've uninstalled the compass and sass gem again. I deleted all compass related gems in the ruby/gems/ruby1.9.1/gems folder (which is probably not necessary, not sure) and than I installed: gem install compass --version "0.12.2" and gem install sass --version "3.2.10". I don't think that the versions here are too important as long as it is not the newest versions of these two. Now the important bit here is to: gem uninstall sass . It will ask you which version to wipe out or if all of them. Delete the newer one. The trick here is that compass installs automatically a newest version of sass. So if you install an older one it doesn't matter as there is already newer one with compass which will get used. Try it.
我有同样的问题。我做了建议 - 使用 --pre 卸载和安装,但这并没有解决我的问题。在那之后我遇到了另一个问题。好吧,我当时所做的是:我再次卸载了指南针和 sass gem。我删除了 ruby/gems/ruby1.9.1/gems 文件夹中所有与指南针相关的宝石(这可能不是必需的,不确定),然后安装: gem install compass --version "0.12.2" 和 gem install sass --版本“3.2.10”。我不认为这里的版本太重要,只要不是这两个的最新版本。现在重要的是: gem uninstall sass 。它会询问您要清除哪个版本,或者是否全部清除。删除较新的。这里的技巧是指南针会自动安装最新版本的 sass。因此,如果您安装较旧的,则没有关系,因为已经有新的带有指南针的将被使用。尝试一下。
回答by Aleksandr Golovatyi
Uninstall SASS: gem uninstall sass
卸载 SASS: gem uninstall sass
Uninstall COMPASS: gem uninstall compass
卸载指南针: gem uninstall compass
Install --pre COMPASS version: gem install compass --pre
安装 --pre COMPASS 版本: gem install compass --pre
Install --pre SASS version: gem install sass --pre
安装 --pre SASS 版本: gem install sass --pre
回答by Amit
Issue got resolved for me when I ran the cygwin command prompt window as administrator.
当我以管理员身份运行 cygwin 命令提示符窗口时,问题得到了解决。
回答by pdp2
I was having a similar issue and I was able to resolve it by un-installing both compass and sass:
我遇到了类似的问题,我能够通过卸载指南针和 sass 来解决它:
gem uninstall compass
gem uninstall sass
Then, all you need to do is install compass:
然后,您需要做的就是安装指南针:
gem install compass
sass is required as part of the compass install so there shouldn't be any need to install it separately. It appears that the issue I was facing was that there was a conflict between the version installed as part of the compass install and the one I installed manually.
sass 是指南针安装的一部分,因此不需要单独安装它。我面临的问题似乎是作为指南针安装的一部分安装的版本与我手动安装的版本之间存在冲突。

