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

Won't run the demo on Windows #3

Open
CrustyAuklet opened this issue Jun 28, 2023 · 2 comments
Open

Won't run the demo on Windows #3

CrustyAuklet opened this issue Jun 28, 2023 · 2 comments

Comments

@CrustyAuklet
Copy link

Just following the steps in the README on windows I run the command renode-run demo --board 96b_nitrogen shell_module and immediately get the following error:

❯ renode-run demo --board 96b_nitrogen shell_module
Renode found in $PATH: C:\Program Files\Renode\bin\renode.EXE. If you want to use the latest Renode version, consider running 'renode-run download'
Binary name `shell_module` is not a local file, trying remote.
12:30:06.7690 [INFO] Loaded monitor commands from: C:\Program Files\Renode\scripts/monitor.py
12:30:07.6430 [INFO] Including script: C:\Users\Ethan\AppData\Local\Temp\tmpjvoizy4u
Fatal error:
The process cannot access the file 'C:\Users\Ethan\AppData\Local\Temp\tmpjvoizy4u' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
   at System.IO.StreamReader..ctor(String path, Encoding encoding)
   at System.IO.File.InternalReadAllLines(String path, Encoding encoding)
   at Antmicro.Renode.UserInterface.Monitor.TryExecuteScript(String filename, ICommandInteraction writer)
   at Antmicro.Renode.UserInterface.Commands.IncludeFileCommand.Run(ICommandInteraction writer, PathToken path)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Antmicro.Renode.UserInterface.Monitor.RunCommand(ICommandInteraction writer, Command command, IList`1 parameters)
   at Antmicro.Renode.UserInterface.Monitor.ExecuteCommand(Token[] com, ICommandInteraction writer)
   at Antmicro.Renode.UserInterface.Monitor.ParseTokens(IEnumerable`1 tokensToParse, ICommandInteraction writer)
   at Antmicro.Renode.UserInterface.Monitor.Parse(String cmd, ICommandInteraction writer)
   at Antmicro.Renode.UserInterface.Monitor.HandleCommand(String cmd, ICommandInteraction ci)
   at AntShell.Shell.HandleCommand(String cmd, ICommandInteraction ic)
   at AntShell.CommandLine.HandleControlSequence(ControlSequence seq)
   at AntShell.Terminal.NavigableTerminalEmulator.HandleInput(Object input)
   at AntShell.Terminal.NavigableTerminalEmulator.Run(Boolean stopOnError)
   at AntShell.Shell.Start(Boolean stopOnError)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart(Object obj)

I have the latest version of Renode installed:

❯ &"C:\Program Files\Renode\bin\renode.EXE" --version
Renode, version 1.13.3.33150 (db556918-202306271823)
CrustyAuklet added a commit to CrustyAuklet/renode-run that referenced this issue Jun 28, 2023
@CrustyAuklet
Copy link
Author

Did some digging, and this is caused by the use of the temporary file, and passing to to the Renode process without closing it first.

Looking at the documentation for tempfile.NamedTemporaryFile it looks like it has two problems as used currently:

  • The default argument for delete is Trues, meaning the file is deleted once closed
  • On windows the file can't be used be another process while still open

I created a fork with a simple fix so I can use it for now, if you want me to open an MR
7445b00

    with tempfile.NamedTemporaryFile(delete=False) as temp:
        temp.write(script.encode("utf-8"))
        temp.flush()
        temp.close()
        ret = subprocess.run([renode_path, temp.name] + args.renode_arguments)

@PiotrZierhoffer
Copy link
Member

Hi @CrustyAuklet

Thanks for reporting this. Renode-run is designed for Linux (as you will see when you run renode-run download), but it's good to hear it can work on Windows as well, at least partially.

Sure, please open a PR, we'll be glad to pull it in.

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