Skip to content

Unable to compile a file under Linux #56

Description

@LyesSaadi

Hello again!

Because it is using Windows-exclusive code, the compiler is unable to compile a program.

Here is the stack trace:

Unhandled exception. System.IO.DirectoryNotFoundException: Could not find a part of the path '/var/home/lyes/.opt/Ncodi/D:/ncodi/cfg.dot'.
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) in /_/src/System.Private.CoreLib/shared/Interop/Unix/Interop.IOErrors.cs:line 24
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) in /_/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs:line 39
   at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options) in /_/src/System.Private.CoreLib/shared/System/IO/FileStream.Unix.cs:line 61
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) in /_/src/System.Private.CoreLib/shared/System/IO/FileStream.cs:line 237
   at System.IO.StreamWriter.ValidateArgsAndOpenPath(String path, Boolean append, Encoding encoding, Int32 bufferSize) in /_/src/System.Private.CoreLib/shared/System/IO/StreamWriter.cs:line 170
   at System.IO.StreamWriter..ctor(String path) in /_/src/System.Private.CoreLib/shared/System/IO/StreamWriter.cs:line 140
   at Ncodi.CodeAnalysis.Compilation.Evaluate(Dictionary`2 variables, Boolean useConsole, Func`1 GetInput, Action`1 send) in /var/home/lyes/.opt/Ncodi/src/Ncodi/CodeAnalysis/Compilation.cs:line 69
   at Ncodi.Program.Main(String[] args) in /var/home/lyes/.opt/Ncodi/src/Nc/Program.cs:line 39

I do not have any experience in C#, but looking at the stack trace, the issue is obviously here:

var appDirectory = Path.GetDirectoryName(appPath);
var cfgPath = Path.Combine("D:", "ncodi", "cfg.dot");
var cfgStatement = !program.Statement.Statements.Any() && program.Functions.Any()
? program.Functions.Last().Value
: program.Statement;
var cfg = ControlFlowGraph.Create(cfgStatement);
using (var streamWriter = new StreamWriter(cfgPath))
cfg.WriteTo(streamWriter);

Looking at it, I wouldn't be surprised if it also causes issues in Windows systems, since it is looking for a configuration file in a hard-coded path.

NOTE: I used compile here, but I have no idea if it's doing any compilation or not TBH since I wasn't able to execute it yet :P !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions