Eugleo / magic-racket

The best coding experience for Racket in VS Code
https://marketplace.visualstudio.com/items?itemName=evzen-wybitul.magic-racket
GNU General Public License v3.0
202 stars 28 forks source link

`open-input-file: cannot open module file` When trying to run file in terminal on Windows #67

Closed shengjiex98 closed 2 years ago

shengjiex98 commented 2 years ago

Environment

Error message

PS C:\Users\Shengjie\Desktop> racket c\:/Users/Shengjie/Desktop/test.rkt
open-input-file: cannot open module file
  module path: C:\Users\Shengjie\Desktop\c\:\Users\Shengjie\Desktop\test.rkt
  path: C:\Users\Shengjie\Desktop\c\:\Users\Shengjie\Desktop\test.rkt
  system error: The filename, directory name, or volume label syntax is incorrect.; win_err=123

Additional context

This occurs when trying to click the green arrow Racket: run file in terminal. Running the command mannual without the \ inserted in the path (i.e. running racket c\:/Users/Shengjie/Desktop/test.rkt manually can run the file just fine.


If relevant, please enclose a minimal example file which triggers the errors. If you're unable to enclose the file, please do the following instead:

No log is generated. Here's the test file:

#lang racket

(+ 1 2)
CatEricka commented 2 years ago

Duplicate of #63

shengjiex98 commented 2 years ago

Duplicate of #63

Thanks for pointing it out. As I understand it the marketplace version is not fixed yet, correct?

CatEricka commented 2 years ago

Thanks for pointing it out. As I understand it the marketplace version is not fixed yet, correct?

https://marketplace.visualstudio.com/items/evzen-wybitul.magic-racket/changelog

Version 0.6.2 fixes this, try updating to the latest version or reinstalling the extension.

CatEricka commented 2 years ago

Version 0.6.2 fixes this

Edit: the bug still exists in 0.6.2 (download from marketplace)

CatEricka commented 2 years ago

I checked the code of version 0.6.2 which download by:

https://marketplace.visualstudio.com/_apis/public/gallery/publishers/evzen-wybitul/vsextensions/magic-racket/0.6.2/vspackage

marketplace version repl.js:

exports.executeSelectionInRepl = executeSelectionInRepl;
function runFileInTerminal(command, filePath, terminal) {
    terminal.show();
    terminal.sendText(`clear`);
    terminal.sendText((0, shell_quote_1.quote)([...command, filePath]));
    // Leaving this here if we ever need to fix cmd.exe again
    // const shell: string | undefined = vscode.workspace
    //   .getConfiguration("terminal.integrated.shell")
    //   .get("windows");
    // if (process.platform === "win32" && shell && /cmd\.exe$/.test(shell)) {
    //   // cmd.exe doesn't recognize single quotes
    //   terminal.sendText(`${racket} "${filePath}"`);
    // } else {
    //   terminal.sendText(`${racket} '${filePath}'`);
    // }
}

fixed version repl.ts:

export function runFileInTerminal(
  command: string[],
  filePath: string,
  terminal: vscode.Terminal,
): void {
  terminal.show();

  if (isWindowsOS()) {
    terminal.sendText(isPowershellShell() || isCmdExeShell() ? `cls` : `clear`);
    const racketExePath = quoteWindowsPath(command[0], true);
    filePath = quoteWindowsPath(filePath, false);
    terminal.sendText(`${racketExePath} ${command.slice(1).join(' ')} ${filePath}`);
  } else {
    terminal.sendText(`clear`);
    terminal.sendText(quote([...command, filePath]));
  }
}

Looks like the wrong file was packaged and published.

shengjiex98 commented 2 years ago

That makes sense. Should I close the issue, or keep it open until it is fixed in the released version?

CatEricka commented 2 years ago

Maybe should keep it open and wait for the author to merge pr (#68) to release a new version ?

Eugleo commented 2 years ago

Should be fixed in 0.6.3. Made sure to package the correct code this time. Please, test this and then close the issue if everything is ok.

MaxweIISmith commented 2 years ago

v 0.6.3 still not work under Windows image

hamidb80 commented 2 years ago

the wrong path that magic-racket generates:

c:/Users/play.rkt

the correct path:

C://Users/play.rkt

NOTE: c:/ and C://

hamidb80 commented 2 years ago

I'm sorry, I was wrong in the last comment. I new to Racket.

the problem is not from generated path.

It's so strange that Racket: Load file in REPL button doesn't work for the first time, but it works after that. see what I mean:

image

as you can see, the first time that the extension passed the code with --eval flag, it raises an error, but the second time that I clicked on that button, it works fine.

is that a Racket issue ?

CatEricka commented 2 years ago

@hamidb80 It's magic-racket's issue (#65, #66) which has been fixed but not published properly: https://github.com/Eugleo/magic-racket/issues/66#issuecomment-1022130597

Eugleo commented 2 years ago

Should be fixed. I manually downloaded the 0.6.4 from the marketplace and checked that the repl.js file is the correct one. Sorry everyone for the mishaps!