Sublime Text 3出现无法保存文件的奇怪现象及几种解决方法 您所在的位置:网站首页 文件显示无法保存到此处是什么原因 Sublime Text 3出现无法保存文件的奇怪现象及几种解决方法

Sublime Text 3出现无法保存文件的奇怪现象及几种解决方法

2024-07-09 12:20| 来源: 网络整理| 查看: 265

Sublime Text 是最近用得比较多的编辑器,也是很流行的工具之一。上手之后码字效率高了很多。

最近本本升级到Win10后,把之前win7的Sublime Text目录直接拷到win10,简单配置了一下就可以正常用了。本以一切如常,突然某天发现把一个文件另存成一个新的文件的时候 每一次都提示类似这么一对话框:

Unable to saveD:\xampp\htdocs\websites\dev.liverpool\style\main.scssError:MoveFileEx(D:\xampp\htdocs\websites\dev.liverpool\style\.sublae1.tmp, D:\xampp\htdocs\websites\dev.liverpoolzstylezmain.scss) failed,Access is denied.

前几次以为是个别现象没去管它,后来一起出现受不了。

内事不决问百度,无果。Bing也无果,只好翻出去问GG了。

在一个论坛找到了几个解决办法,先和大家分享一下,但最终我个人的解决方法却是个诡异的现象。

先说国外网友的几个方法,原帖:http://stackoverflow.com/questions/18264507/sublime-text-unable-to-save

一、让Sublime Text 以管理员身份运行(这招对我无效)

1. Go to the path where you installed sublime text 2 and...2. Right click on the sublime_text 2.exe file.3. Go to its properties.4. Go to compatibility section under this.5. Set its privilege level to "Run this program as an administrator".6. Now change settings for all users and there also check the field "Run this program as an administrator".7. Apply the changes.

大概意思就是:右击Sublime Text -> 属性 -> 兼容性 -> 选中以管理员身份运行 -> 更改所有用户设置 -> 以管理员身份运行,确定保存

我测试了一下,操作后每次运行 Sublime Text 都会有Windons 安全风险提示。这不重要,重要的是问题没有解决,还是会出现之前的问题。但论坛上有人反应他通过这种方式解决了问题。

二、认为是权限问题,给Sublime加所有权限(对我也不效,且我觉得这个思路也不对)

I just solved the same issue on Sublime Text 3 beta, Stable Channel Build 3065 by doing the following under Windows 7:

1. Navigate to the Sublime Text 3 executable file, wherever you have it installed.2.Right-click it and select properties.3.Click on the tab marked "Security"4.About half way down the tab, on the right hand side, under the list of group and user names is this little button:Click it.

5. If your machine is setup the way I suspect it is (otherwise you probably would not be having this issue), you should be prompted for your administrator account credentials. Enter them.Now, select the Users group in the list, then take a look in the box at the bottom labeled 'Permissions for Users'. Put a check mark in the 'Allow' column for the 'Write' item.

6. Click 'Apply'7. Click 'OK'You should be set. What this does is it essentially gives Sublime the ability to write files while running with regular user privileges, no administrator level access required. Upon taking a better look at your error, what is happening is Sublime Text is creating a temp file for editing, rather than editing to file itself, then attempting to overwrite the original file with the temp on save. The problem is that the program is not being run by a user with sufficient privileges to perform the overwrite, hence the failure with an 'Access denied' message.

大概意思就是让sulime text.exe给users用户组加上所有权限。我试了无效,还把所有的用户都加了所有权限,也无效。我觉得这个方法的思路可能不对,于是我把目光转向了保存目录的权限,加了everyone的所有权限都加上。依然不行。

三、关闭Sublime Text的atomic_save(这招有效,但我却不希望关掉)

1、打开Sublime Text2、首选项 -> 设置-用户3、配置中加一行:"atomic_save": false,4、保存,再试问题解决了。

到此,问题好像解决了。

  但是,心下很不爽,不知道这是什么意思,感觉是把自动保存给关闭了?为什么关闭了这个就可以了?按提示是说SublimeText是在把.tmp文件移过成目标文件的时候出错了,猜是目标文件可能被占用或者锁定了。于是我试了一下在其它目录下进行类似的操作,发现其它目录下竟然没问题。好像越来越接近真相了。仔细思索两目录的不同,感觉可能和我用了群晖的同步功能有关(是的,你没看错,我辜负了你们,快盘倒后,自称“不会停服”的360也打脸了。我只能忍痛转用了群晖。这不是广告)。

  想定,我把同步关闭,问题好像真的就解决了。但诡异的是之前打开同步的时候明明是显示同步完成了的状态。为什么还会有文件冲突?难不成是群晖对我“隐瞒了什么”?不得而知。但总不能为了这个而不同步吧。继续找碴,最终发现解决问题的关键在这:

由原来的在服务器上保留版本改成保留最新修改的版本后问题解决

但是,但是,为什么同样的情况,win7下不会出这问题?我的答案是,win7时我是把文件放在ssd盘上做同步的,win10是放在普通HD硬盘,可能跟这个速度有关。姑且这么想吧。虽然没有真正发现问题的原因,但问题总算被“完美”解决了。

把这个问题发出来,以便有朋友也不小心掉进类似的坑。遇到这样的问题,第一时间要排查是不是有什么进程对目标文件进行了锁定之类的限制。

如果你有更好的答案,恳请不吝赐教。

夜深不及校对文字,有误之处还请见谅!



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有