“Errno::EACCESS…permission denied” running compass watch

后端 未结 9 1149
清酒与你
清酒与你 2020-12-28 08:49

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.

I have tri

9条回答
  •  北荒
    北荒 (楼主)
    2020-12-28 09:27

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

    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:

    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.

提交回复
热议问题