FreeCAD icon indicating copy to clipboard operation
FreeCAD copied to clipboard

[Problem] Windows: FreeCAD can open but not save a file with a Junction in the path (only supported in Qt6.2)

Open tbird1965 opened this issue 2 years ago • 9 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Problem description

Because Windows' One Drive has very long paths (including spaces - ugh), I use a Junction as a shortcut on my filesystem:

Directory of D:\
09/14/2022  08:22 AM   <JUNCTION>     documents [d:\OneDrive - My Company Name\Documents]

If I have a FreeCAD file at d:\documents\bug\panel.FCStd, I can navigate to the junction d:\documents\bug\panel.FCStd and click it to open it via file explorer without issue: click-opens-fine

However, when I hit save, I get the following error message: 2023-09-27 11_52_49-Could not save document

To save it, I have to chose "Yes" and then navigate to the actual path d:\OneDrive - My Company Name\Documents\bug\panel.FCStd to save it.

For testing, I created a directory symlink: 09/27/2023 11:32 AM <SYMLINKD> doc [d:\OneDrive - My Company Name\Documents]. FreeCAD will open/save using a directory symlink, but since Windows only lets admins create directory symlinks and symlinks redirect differently when viewing via a remote system, I'd prefer using a junction.

I also noticed that using File | Open with a junction displays the junction path d:\documents\bug, but if I use File | Open and click a directory symlink, I see the original D:\One Drive - My Company Name\Documents path in the navigation bar. This does not occur in File Explorer, so somehow the open dialog is doing something different.

FreeCAD File | Open when navigating using junction (desired display): open-clicking-junction

FreeCAD File | Open when navigating using directory symlink (not desired display): open-clicking-dir-symlink

Windows File Explorer when navigating using directory symlink (desired display): file-explorer-via-symlink

Full version info

[code]
OS: Windows 10 build 19045
Word size of FreeCAD: 64-bit
Version: 0.21.1.33668 +26 (Git)
Build type: Release
Branch: (HEAD detached at 0.21.1)
Hash: f6708547a9bb3f71a4aaade12109f511a72c207c
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: English/United States (en_US)
[/code]

Subproject(s) affected?

None

Anything else?

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

tbird1965 avatar Sep 27 '23 16:09 tbird1965

Why do use <Junction> in the filename ? I'm still not clear on that.

luzpaz avatar Sep 27 '23 16:09 luzpaz

If you are referring to the directory of D drive - that is just how the command prompt tells you there is a junction defined between the word documents and D:\OneDrive - My Long Company Name is Here\Documents

Using PowerShell, maybe it is clearer - showing my normal junction link and my test symbolic link:

PS D:\> Get-ChildItem . -Force `
>>   | ?{ $_.LinkType } `
>>   | Select FullName, LinkType, Target

FullName     LinkType     Target
--------     --------     ------
D:\doc       SymbolicLink {d:\OneDrive - My Long Company Name\Documents}
D:\documents Junction     {d:\OneDrive - My Long Company Name\Documents}


PS D:\>

If you are asking why I even use a junction, at least in the Windows world, a junction is a local directory mapping. It is like a file hard link but for directories. Without the junction, my paths would be always very long and include spaces like:

D:\OneDrive - My Long Company Name is Here\Documents\projects\customers\custA\project23\size_26_panel\datasheets

With the junction, I can have this (and never see D:\OneDrive - My Long Company Name is Here or the spaces in the filename:

D:\documents\projects\customers\custA\project23\size_26_panel\datasheets

As a "standard" user, I can set and remove junctions without rights elevation. Symlinks require elevation.

PS: Microsoft defines the OneDrive path with company name and spaces on all corporate PCs - you have no chance to change it - unless you change your company name - but it will always come with spaces around the hyphen.

tbird1965 avatar Sep 27 '23 18:09 tbird1965

Any relationship with #5592 and #7596

luzpaz avatar Sep 27 '23 19:09 luzpaz

Both https://github.com/FreeCAD/FreeCAD/issues/5592 and https://github.com/FreeCAD/FreeCAD/issues/7596 refer to symlinked files only and am not sure if that really applies to directories. FreeCAD seems to be 98% working with directory symlinks/junctions. I don't have any problems of a second file appearing as mentioned in those tasks you list. I just cannot click File | Save when I have opened the file using a directory junction. Additionally, if I switch to a directory symlink, then the file dialog box shows the real path and not the symlink version - so technically "works", but is not as desired.

I have found that FreeCAD shows the file project info correctly (shows junction for the path) when you view File | Project Info (it just fails on File | Save).

D:/documents/bug/panel_size26.FCStd is the path with the junction in use correctly, which is shown in the project info.

The actual path I have to navigate to so I can actually resave my file after changes is (i.e. can't use the junction):

D:\OneDrive - My Company Name\Documents\bug\panel_size26.FCStd:

project_info

tbird1965 avatar Sep 27 '23 21:09 tbird1965

User can create symlinks without elevation of privileges on Windows 10. ^1 I use them instead of junctions.

Qt has functions to avoid this kind of trouble, like QString QFileInfo::junctionTarget() and std::filesystem::path QFileInfo::filesystemJunctionTarget(), however, they were introduced in Qt 6.2. ^2 Maybe, it's for the best to address this issue after the transition to Qt 6.

xtemp09 avatar Dec 02 '23 11:12 xtemp09

@xtemp09 - The Windows blog is interesting, but standard mode of Windows 10 still requires elevation. User must go into Developer mode. It is unclear since I am using a corporate machine, a) if I physically can (appears I am blocked), and b) what side effects will result. Windows 11 looks to have dropped the admin requirement for symlinks.

tbird1965 avatar Jan 08 '24 14:01 tbird1965

I have the same issue - I cannot save into a folder on a junction path. For me, as soon as I click 'Save', FreeCAD hangs. Even with a "FreeCAD.log" file being generated, no new entries appear from the moment I click Save.

My use of Junction is for slightly different reasons - all users have established a consistent structure: C:\Projects, and within that are individual projects. There's no junction in this example, but several PCs didn't have a large C drive, so c:\Projects was the junction to D:\Projects. Others would like the C:\Projects to map to a network path.

[code] OS: Windows 10 build 19045 Word size of FreeCAD: 64-bit Version: 0.21.2.33771 (Git) Build type: Release Branch: releases/FreeCAD-0-21 Hash: b9bfa5c5507506e4515816414cd27f4851d00489 Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3 Locale: English/United States (en_US) Installed mods:

  • pcb 6.2023.1

[/code]

File | Project Information shows: [code] C:/Projects/SweeperConcept/Mechanical/Enclosure_Main.FCStd [/code] even as this is on D:/Projects/SweeperConcept/...

I have tracked most of the FreeCAD releases since 0.16, and I did not use to have this problem [as best I recall], so I guess this came along with an update to Qt - perhaps 0.19?

Wiredhome avatar Jan 29 '24 17:01 Wiredhome