【问题标题】:"Errno::EACCESS...permission denied" running compass watch“Errno::EACCES ...权限被拒绝”运行指南针手表
【发布时间】:2014-05-01 02:10:45
【问题描述】:

我刚刚将我的项目文件迁移到 D: 驱动器上的新 PC 上,而我的程序(Git、Node Js、Ruby 等)位于 C: 驱动器上。

我在编辑 SASS 文件后尝试运行 compass watch,但遇到此错误:

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

我是命令行 Ruby 的新手(因为我只将它用于 Web 开发目的)。我需要做什么才能允许这些权限?

如果我可以提供更多信息,请告诉我。

编辑: 这是运行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.

不过我不知道该怎么做。

通过阅读 (https://github.com/chriseppstein/compass/issues/1406) 我相信这与 “Ruby”和“Ruby Gems”的权限或 PATH 有关,但我不知道如何解决这个。

【问题讨论】:

  • 您是否尝试过使用--trace 运行,就像它建议的那样找出问题所在?
  • 是的,之前给过的。它刚刚返回'--trace' is not a recognized...
  • 啊……刚刚发现它实际上意味着运行compass watch --trace(感觉很密集)!我会用详细信息更新问题。
  • 我遇到了同样的问题并解决了重新安装 gems like this guy did.
  • 我试过了,但我得到了同样的错误。

标签: ruby windows sass compass-sass


【解决方案1】:

为了让它在 32 位或 64 位窗口中工作,我按照 Min Ren 的建议做了,但在卸载步骤之后,我还必须手动清理所有 sass 和 compass gemspec 文件的 gem 存储库 (C:\Users\myusername\.gem\specs\rubygems.org%443\quick\Marshal.4.8)。我还在 compass 之前安装了 sass。

gem uninstall compass
gem uninstall sass

手动清理.gem

gem install sass --version "3.2.10"
gem install compass --version "0.12.2" 

【讨论】:

  • 我通过对 SASS 和 Compass gem 进行各种卸载和重新安装,最终成功地完成了这项工作。不得不使用这个(&敏仁)答案中提到的版本。想知道新版本的 SASS 何时会解决该错误。感谢大家的帮助。
  • 谢谢它帮助了我
  • 为我工作。谢谢!
【解决方案2】:

我有一段时间遇到同样的问题,最终手动修复了它。经过一番挖掘,问题似乎是在 util.rb 中,临时文件正在被重命名在文件关闭之前。在 Windows 中,这显然是不允许的(尽管我不知道为什么我在过去一直在工作后突然开始遇到问题)。

我的解决方法是编辑 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

这里的一个重要警告是,我不是 Ruby 人,我确信可能有更好的方法。但是我只是快速尝试了这个mod,它确实有效,所以我没有投入更多。

【讨论】:

  • sass-3.4.5 仍然存在问题
【解决方案3】:

这看起来像是最新版本的 Sass 中的一个错误。

卸载 Sass 和 Compass 并安装旧版本可解决此问题。

可能会有更新的版本可以工作,但这是我测试过并且知道工作的版本。

gem uninstall compass
gem uninstall sass

gem install compass -v "0.12.2"
gem install sass -v "3.2.13"

【讨论】:

    【解决方案4】:

    看起来问题已在 SASS 3.2.19 中解决

    所以你只需要gem update compass

    【讨论】:

      【解决方案5】:

      我遇到了类似的错误,但解决方案完全不同,所以我认为值得分享一下,以防其他人遇到我的情况。

      实际上,我的权限被拒绝了,因为我的源代码控制已将我的 .css 文件设为只读。解决方案很简单,只需检查 css 文件,一切就恢复正常了。

      【讨论】:

      • 这并不能真正回答问题。如果您有其他问题,可以点击 提问。一旦你有足够的reputation,你也可以add a bounty 来引起对这个问题的更多关注。
      • @pangpang 它确实回答了这个问题。如果您不这么认为,请解释您为什么这么认为。
      • 不知道为什么会有仇恨 - 这正是我的问题!不知何故,更新到 El Capitan 会更改我文件夹的权限。非常感谢!
      【解决方案6】:

      我遇到了同样的问题。我做了建议 - 使用--pre卸载和安装,但这并没有解决我的问题。在那之后我遇到了另一个问题。好吧,我当时所做的是:我再次卸载了 compass 和 sass gem。我删除了 ruby​​/gems/ruby1.9.1/gems 文件夹中所有与指南针相关的 gem(这可能不是必需的,不确定),然后我安装了: gem install compass --version "0.12.2" 和 gem install sass --版本“3.2.10”。我不认为这里的版本太重要,只要它不是这两个的最新版本。现在重要的一点是: gem uninstall sass 。它会询问您要清除哪个版本或是否全部清除。删除较新的。这里的诀窍是 compass 会自动安装最新版本的 sass。因此,如果您安装较旧的,则无关紧要,因为已经有带有指南针的较新的可以使用。试试看。

      【讨论】:

        【解决方案7】:

        卸载 SASS:gem uninstall sass

        卸载指南针:gem uninstall compass

        安装--pre COMPASS 版本:gem install compass --pre

        安装 --pre SASS 版本:gem install sass --pre

        【讨论】:

        • 我已经尝试过这样做并且我得到了某个地方......但是我在“Foundation”.scss 文件中收到了大量的折旧警告。主要问题是它返回LoadError on line ['55'] of C: cannot load such file -- wdm
        • 我用各种版本的 Ruby 等多次尝试了整个清理/重新安装过程。它从来没有为我工作过。最终奏效的是我在答案中发布的内容。
        • @user3455260 出于礼貌,下次您复制/粘贴其他用户的答案时,至少给他们一些信任,或链接到它。
        【解决方案8】:

        我遇到了类似的问题,我可以通过卸载 compass 和 sass 来解决它:

        gem uninstall compass 
        gem uninstall sass
        

        然后,您需要做的就是安装指南针:

        gem install compass
        

        sass 是 compass 安装的一部分,因此不需要单独安装。看来我面临的问题是作为指南针安装的一部分安装的版本与我手动安装的版本之间存在冲突。

        【讨论】:

        • 你在什么操作系统上运行它?这在 CentOS 7 上对我不起作用。
        【解决方案9】:

        当我以管理员身份运行 cygwin 命令提示符窗口时,问题得到了解决。

        【讨论】:

          猜你喜欢
          • 2016-07-20
          • 1970-01-01
          • 2011-12-28
          • 2015-07-20
          • 2016-03-14
          • 2014-01-24
          • 2019-02-13
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多