Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled exception. System.IO.IOException: Read-only file system : '/{classname}.xml' #94

Open
lightxx opened this issue Feb 12, 2025 · 4 comments

Comments

@lightxx
Copy link

lightxx commented Feb 12, 2025

on MacOS, this happens:

Discussed in #93

Originally posted by lightxx February 12, 2025
when i run dotnet azure-apim-policy-compiler --s ./Ts.Apis.Policies --o . --format true I get

File UserDtoPolicy Processing
Unhandled exception. System.IO.IOException: Read-only file system : '/UserDtoPolicy.xml'
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at System.IO.File.OpenHandle(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.File.WriteToFile(String path, FileMode mode, String contents, Encoding encoding)
   at Program.<Main>$(String[] args) in C:\repos\experiments\apim-policy-toolkit\src\Compiling\Program.cs:line 67

where Ts.Apis.Policies/UserDtoPolicy.cs is one of my classes containing a policy.

% dotnet --version
8.0.302
% sw_vers -productVersion 
15.3

MacOS

@lightxx
Copy link
Author

lightxx commented Feb 12, 2025

I see the problem is the outdated release package ... Will try to build from source using the latest commit in main tomorrow

@lightxx
Copy link
Author

lightxx commented Feb 12, 2025

anyway, the problem is this line

string targetFolder = Path.GetFullPath(Path.Combine(options.OutputFolder, Path.GetFullPath(file).Split(Path.GetFullPath(options.SourceFolder))[1].Replace(Path.GetFileName(file), "")));
which always returns / on MacOS which is always readonly.

@lightxx
Copy link
Author

lightxx commented Feb 13, 2025

Doesn't work on Windows either. I'm wondering if this thing works at all.

@Mielek
Copy link
Collaborator

Mielek commented Feb 19, 2025

Hello @lightxx ! Thank you for bringing this issue to our attention. We really appreciate your effort in doing that!

Could you please share class definition with Document attribute from UserDtoPolicy.cs? It would help me check why you are facing this issue.

We are now relying on the GitHub actions to run compiler on example project to check this code. I think we could extract it to test it in unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants