Closed brittmalka closed 4 years ago
Approve the bug. Old files that create by other editors are saved in MM. This means problem probably appear when a newest file created by unknown user within MM.
@brittmalka Not sure what would cause this. Pretty sure it has to be file permissions - either your account doesn't have rights or a file is already open by some other application that's holding a lock. Check for file attributes perhaps and try saving the same file/location in another application.
Nothing has changed in Markdown Monster's file handling across recent versions that would change this behavior and I certainly don't see it here.
I tried saving it with Notepad++ in the exact same location and with the same name and with the extension .md, and it worked with Notepad++.
It was a completely new file I made, and it hadn't been opened in any program before.
I updated MM Friday after I'd created my files that day. Is it possible to find an older version of MM from before the last update, so I can test that? I've never had this problem before. I updated Windows 10 last week, but I don't remember which day it was.
I just had a thought and ran MM as admin, but I got the same error.
@brittmalka Not sure what would cause this. Pretty sure it has to be file permissions - either your account doesn't have rights or a file is already open by some other application that's holding a lock. Check for file attributes perhaps and try saving the same file/location in another application.
Nothing has changed in Markdown Monster's file handling across recent versions that would change this behavior and I certainly don't see it here.
I have all permissions (almost full access, exclude especial, that I made special for the situation) to disk where I save Portable MM from zip. I can't save a file that I create from MM menu. It's strange...
@brittmalka Yes old versions are available on Github:
https://github.com/RickStrahl/MarkdownMonsterReleases/tree/master/v1.23
I've also just released a new version (1.23.16).
What are you doing exactly? Are you saving a file as is (ie. Save or Save As from the File menu). Or something else.
@stranger777 as a standard user you can only save files in User folders (ie. under your c:\YourUserName) unless your user account has explicit permissions. You can't save say in c:\
or c:\Program Files
for example. Can you check saving a file into anywhere My Documents
folder? That should always work and will rule out permissions. (also check next message)
Can you do the following just to be sure that there's not some user weirdness:
Is it running the current logged on user or something else?
Is it running the current logged on user or something else?
@RickStrahl the user of MM process and logged user is same. I tried run MM as Administrator and at the same time saved in user home (%USERPROFILE%
) folder and even in system32 (because of I was Administrator :D). Also as standart user in home folder. No effect.
Hmmm... I really have no idea what could cause this. are you on the latest version (updated today).
I have 3 different Windows installs here and all of them work just fine saving files as expected. Not saying there isn't a problem but I'm not sure what could be different especially since I can't think of anything that has changed in the file saving code in recent updates. That code hasn't been touched in quite a while.
What version where you on before @stranger777 and @brittmalka that worked? Also, what type of install? Full install or portable? Portable on a network drive may cause permissions issue due to security policy. You might want to try the full install to see if that fixes the issue - but that seems odd too and even weirder to see two people run into this now. I haven't seen anything else to this effect.
The only other thing I can think of is that somehow some Anti-Virus software is perhaps interfering and flagging MM as a malicious?
When I wrote the ticket, I had just updated Friday (Aug 14 my time), but not used it after the update. Then when I couldn't save files with it, I uninstalled it and got the latest version from Aug 15 (1.23.15.7), which I used when I wrote the ticket. I've now upgraded to 1.23.16.0, but unfortunately, I still can't save. I update every time I get a message from the program, and I use it daily (for writing autoresponder emails in HTML). But I didn't notice what version number I had until Friday. It must have been 1.23.15.something.
I download the setup.exe files, full install.
I don't use Antivirus - unless that latest Windows update did something. Let me check. - Still no antivirus.
I've tried both Save and Save as.
Task manager told me that MM is running under user "malka" which is me, and I'm the only user of this computer.
It's weird that we're only two to have the problem. What computer are you on @stranger777 ? I'm on an Alienware core i9. I'm asking, because when we got them, we couldn't run a program called FastKeys until I found out it was a service that made it unable to run.
This doesn't sound like a hardware issue. I'm pretty sure this has something to do with security and/or permissions although I don't know what it could be. MM runs as a standard app so it should have access to everything your account has access to.
I took one of my other machines, completely wiped MM from it, then did a portable install first to a USB drive. Installed ran and everything works including saving. Then nuked everything again and did a full install and it worked that way too.
I'm just not sure what else to check. Two intrusive things I can think of:
I can't see the error in my logs because a file error is so common (invalid filenames, permissions etc.) but this seems like it's something different.
One more thing that has changed: MM now supports file encodings - I wonder if perhaps a funky file encoding is used that's causing a problem? What does the file encoding say on the status bar:
In playing around with that a bit I see there's some inconsistencies when switching formats (which shouldn't be done unless one needs to switch formats to read a file anyway), but nothing like what you describing.
Bingo!
The file encoding said UTF-8 with BOM (whatever that is) and when I changed it to UTF-8, it worked. I can now save the files.
It's stupid, because I looked at that encoding yesterday and since I knew I used UTF-8, I didn't think too much about the "with BOM" part. I should have tested.
Thank you for your help. Now I can save again. Awesome 👍
Ok great at least we have a hint now. However still baffled why with BOM fails. I tried it here and I can open and save docs with Bom (it’s a document identifier prefix -a standard format). I’ll check more closely tomorrow. Certainly looks like there’s a bug there somewhere and that code has changed recently.
Thank you for your help...
You're welcome. Glad to have been of help.
So after poking around a bit in the code the problem seems to be this:
I've fixed the default encoding assignment and fixing up the encoding if the encoding can't be resolved from the file format.
I couldn't make this fail before the fix if I used existing documents but I could make a it fail with a new document before the encoding was assigned.
IAC, I've added some logging in addition to the Encoding fix ups, so if this continues I should see errors in my log that should help track this down if still a problem.
If you both could try 1.23.16.2 or later with whatever was failing before, that would be awesome.
Installed 1.23.16.2 and created a new file, UTF-8 with BOM (it was set as default again). Nope, same error message. So I switched to UTF-8, and saved.
But if you create a new file now, it will say UTF-8, and if I switch to BOM, it still saves.
I closed MM, started it again, and it's on BOM as default.
Created a new file, saved (Save, not Save as), same error, but as you can see here, the file name is there:
However, when I check the folder, the file is not saved.
I hope this helps.
If you both could try 1.23.16.2 or later with whatever was failing before, that would be awesome.
I installed 1.23.16.2. Problem solved not immediately, but only when I changed UTF-8 with BOM to UTF-8. as you said above. Now MM basically works. Thanks for your work!
@brittmalka I think the problem is if you don't save the file the BOM is not actually applied. If there are no changes in the file the new encoding isn't saved to disk.
I think that's why you are seeing the file switch encoding even though you changed it. If you make change to the file and save or Save As the change should take.
Can you check the Errorlog and see if there are entries for Encoding errors at the end (Help -> Show Errorlog)
Thanks for following up and helping to track this down!
Can you check the Errorlog and see if there are entries for Encoding errors at the end (Help -> Show Errorlog)
18.08.2020 23:54:04 - Document Save Failed: Value cannot be null. Parameter name: encoding Markdown Monster v1.23.16.2 6.1.7601.23807.amd64fre.win7sp1_ldr.170512-0600 - ru-RU - NET 4.8 - 32 bit ru-RU - ru-RU
mscorlib at System.IO.File.WriteAllText(String path, String contents, Encoding encoding) at MarkdownMonster.MarkdownDocument.Save(String filename, Boolean noBackupFileCleanup, SecureString password) in C:\projects\MarkdownMonster\MarkdownMonster_Classes\MarkdownDocument.cs:line 679
Thanks @stranger777 - argh. Issue on my end - there was no default encoding and it fails before files are properly loaded. Anyway give .4 a try.
@brittmalka This update also marks the document as dirty so you can actually save the encoding change without some other change in the document being required as before which should avoid the confusion of the encoding change not actually working when re-opening.
Thanks to both of you for sticking with me on this - I appreciate the help.
I am seeing a problem when trying to open files that are UTF8. If I use VSCode to save them as UTF8 with BOM then MM can open them. Otherwise it states Can't Open file as a error. Nothing in the error log.
Version: v1.23.16.2
@sytone can you try 1.23.16.4 please? I think that has the issue fixed now.
So here are all the scenarios that I think might have been failing before but shouldn't anymore:
This uses VS Code to write out files with different encodings and loads them in MM and saves the files, changes the encoding and rewrites.
Note that VS Code doesn't detect the encoding change (which is interesting because the file actually changes with the prefix for BOM), but MM does detect when VS Code changes the encoding.
Updated and can now open the files without error however MM shows they are UTF8 with BOM and VSCode shows without. If I have time will look at that but I need to get a document updated :)
If you changed the encoding in MM and saved the file, then VS Code has to reload the document to see the Encoding change. It works correct as far as I can see - the screen capture above shows just that scenario in reverse (switching from BOM to without) and having to reload the VS Code doc to see the change.
Good morning :)
Here's the clip from the error log:
I made a short video that shows what happens from I open MM, create a new file, save and fail - . then change the encoding to UTF-8 and save.
Perhaps my MM starts with BOM because I live in Israel and I also have Hebrew keyboard and language installed?
@brittmalka bug fixed in this setup: https://github.com/RickStrahl/MarkdownMonsterReleases/blob/master/v1.23/MarkdownMonsterSetup-1.23.17.exe
Perfect. Thank you very much, both of you.
Updated to 1.23.17 and when opening files the encoding matches what other programs are seeing, nice work! No to get it working with Hexo.
Ok looks like everyone is getting the proper results now as of 1.23.17. Both issues - not saving and properly setting and storing the encoding (plus the dirty document to indicate that the document needs to be saved for the encoding change to be written.
If there's still a problem with 1.27.17 you can re-open this issue.
Thank you all for your help...
I used MarkdownMonster Friday, updated it, and today I cannot save files at all.
I get the following error message:
D:\Dropbox\Documents\mails\test4.md This document can't be saved in this location. The file is either locked or you don't have permissions to save it. Please choose another location to save the file.
I have tried:
I've also tried to search for solutions to this, but I saw nobody else with that problem. Which points towards me as the problem, but I don't see what I could have done wrong.
Thanks, Britt