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

"Cannot import files outside of module root directory" #485

Open
juliangruber opened this issue Feb 7, 2024 · 30 comments
Open

"Cannot import files outside of module root directory" #485

juliangruber opened this issue Feb 7, 2024 · 30 comments
Assignees
Labels
bug 🐛 Something isn't working

Comments

@juliangruber
Copy link
Member

juliangruber commented Feb 7, 2024

This error was submitted by a user in https://filecoinproject.slack.com/archives/C03S6LXSRB8/p1707311859950409:

[2024-02-07T13:25:54Z ERROR zinniad] Cannot import files outside of module root directory \\?\C:\Users\Administrator\AppData\Local\Temp\Filecoin Station Desktop\sources\voyager. file:///C:/Users/ADMINI~1/AppData/Local/Temp/Filecoin%20Station%20Desktop/sources/voyager/main.js

{"type":"activity:info","module":"Zinnia","message":"Voyager exited with code: 1"}

This is the first time I've seen that error, other installations are looking fine.

Some suspicions:

  • Could this be a filesystem case sensitive problem?
  • Is this another error masking as this one?

Zinnia source of error:

format!("Cannot import files outside of module root directory {}. ", module_root.unwrap().display())

Mentioned Voyager file: https://github.com/filecoin-station/voyager/blob/4f4410c36df95774e6f52cabf717c322e27e6693/main.js

@bajtos
Copy link
Member

bajtos commented Feb 7, 2024

I find it suspicious that module_root starts with \\?. It looks like some kind of a path to a network-shared drive.

@juliangruber
Copy link
Member Author

@bajtos
Copy link
Member

bajtos commented Feb 8, 2024

Could be! But I don't think so necessarily https://stackoverflow.com/questions/21194530/what-does-mean-when-prepended-to-a-file-path

Great find!

Another interesting fact:

The module toot directory contains Administrator among the directory names, while the module URL contains AMINI~1.

I suspect Deno uses a process for converting paths to strings on Windows that is different from Zinnia's.

@juliangruber What is the impact of this issue? How many users are affected?

@bajtos
Copy link
Member

bajtos commented Feb 8, 2024

I think this may be fixed by filecoin-station/core#345. Let's see if the problem persists after people update their Station versions to apply that patch.

@juliangruber
Copy link
Member Author

yeah! I'm releasing the changes atm, to validate this

@juliangruber
Copy link
Member Author

Released in https://github.com/filecoin-station/desktop/releases/tag/v1.3.8, asked user for confirmation

@juliangruber
Copy link
Member Author

Let's reopen if the issue comes back

@juliangruber
Copy link
Member Author

juliangruber commented Feb 22, 2024

This issue came back. This time it was also captured with Spark. The paths all look correct. I assume this is a cross platform path handling issue.

[2024-02-21T18:21:47Z INFO zinniad] Starting zinniad with config CliArgs { wallet_address: "", state_root: "C:\Users\\AppData\Local\Filecoin Station Desktop\modules\zinnia", cache_root: "C:\Users\\AppData\Local\Temp\Filecoin Station Desktop\modules\zinnia", files: ["spark\main.js"] }

[2024-02-21T18:21:47Z INFO lassie] Starting Lassie Daemon
[2024-02-21T18:21:47Z INFO lassie] Lassie Daemon is listening on port 64945
{"type":"activity:info","module":"spark","message":"Spark started"}

[2024-02-21T18:21:47Z INFO zinniad] Starting module file:///C:/Users//AppData/Local/Temp/Filecoin%20Station%20Desktop/sources/spark/main.js

[2024-02-21T18:21:48Z ERROR zinniad] Cannot import files outside of module root directory \?\C:\Users<REDACTED>\AppData\Local\Temp\Filecoin Station Desktop\sources\spark. file:///C:/Users//AppData/Local/Temp/Filecoin%20Station%20Desktop/sources/spark/main.js

{"type":"activity:info","module":"Zinnia","message":"Spark exited with code: 1"}
{"type":"activity:error","module":"Zinnia","message":"Zinnia crashed"}
Zinnia closed all stdio with codes 1, 1

I formatted the logs for better readability.

Suspicious: Zinnia is seeing relative paths as args files: ["spark\\main.js"], but then printing absolute paths when starting Starting module file:///C:/Users/<REDACTED>/AppData/Local/Temp/Filecoin%20Station%20Desktop/sources/spark/main.js That's not it. The same output can be seen on macOS, where this works

@juliangruber juliangruber reopened this Feb 22, 2024
@juliangruber
Copy link
Member Author

I cannot reproduce this on my Windows 11 Pro laptop

@juliangruber
Copy link
Member Author

I have asked the issue reporter for additional details on their setup. This bug is preventing them from using Zinnia.

@bajtos
Copy link
Member

bajtos commented Feb 22, 2024

Can you create a user on your Windows laptop with a long username and/or a username containing non-ASCII characters? Would that reproduce the problem?

I assume this is a cross platform path handling issue.

Yeah, I am thinking the same. Windows have several different ways how to encode filesystem paths. Preserving backwards compatibility all the way back to MS-DOS and 8.3 filename format comes with costs.

@juliangruber
Copy link
Member Author

Can you create a user on your Windows laptop with a long username and/or a username containing non-ASCII characters? Would that reproduce the problem?

From the original error reporting I can tell that the username in question consists of [a-z]{5}, so that seems not to be it.

Yeah, I am thinking the same. Windows have several different ways how to encode filesystem paths. Preserving backwards compatibility all the way back to MS-DOS and 8.3 filename format comes with costs.

😱

@bajtos bajtos added the bug 🐛 Something isn't working label Feb 27, 2024
@bajtos
Copy link
Member

bajtos commented Feb 27, 2024

@juliangruber what's the severity/priority of this issue? Should we prioritise it for the next milestone?

@juliangruber
Copy link
Member Author

We have only heard about this from one user. They are not able to participate at all because of this. We don't know how many blocked users we aren't aware of. I propose we as a team discuss the severity of this issue.

@bajtos
Copy link
Member

bajtos commented Jun 28, 2024

It happened again, see filecoin-station/desktop#1639

[2024-06-28T04:24:00Z INFO  zinniad] Starting module file:///C:/Users/Win/AppData/Local/Temp/Filecoin%20Station%20Desktop/sources/spark/main.js
[2024-06-28T04:24:00Z ERROR zinniad] Cannot import files outside of module root directory \\?\C:\Users\Win\AppData\Local\Temp\Filecoin Station Desktop\sources\spark. file:///C:/Users/Win/AppData/Local/Temp/Filecoin%20Station%20Desktop/sources/spark/main.js

@bajtos
Copy link
Member

bajtos commented Jun 28, 2024

@teo4RM4Z @nekros05 Do you have any idea why Station sees the path where it's installed with the prefix \?\C:\Users?

Edit: I think the prefix is actually \\?\C:\Users

@nekros05
Copy link

I don't know, it was installed in the default routes, the real route is this "C:\Users", could you tell me where that route is saved? Maybe I can change it and it can be fixed

@teo4RM4Z
Copy link

teo4RM4Z commented Jun 30, 2024

@teo4RM4Z @nekros05您是否知道为什么 Station 会看到带有前缀的安装路径\?\C:\Users

编辑:我认为前缀实际上是\\?\C:\Users

I I have uninstalled Filecoin station
Redownloaded 1.8.6 and install to C:\filecoin station
The Crashed still exists .
2024-06-30_17-21-16

New log:
station-modules-1719740157976.log

@bajtos bajtos changed the title "Cannot import files outside of module root directory" with voyager "Cannot import files outside of module root directory" Jul 1, 2024
@bajtos
Copy link
Member

bajtos commented Jul 3, 2024

Zinniad logs from the log file attached in the comment above:

Starting module file:///C:/Users/testname/AppData/Local/Temp/Filecoin%20Station%20Desktop/sources/spark/main.js
Cannot import files outside of module root directory \\?\C:\Users\testname\AppData\Local\Temp\Filecoin Station Desktop\sources\spark. file:///C:/Users/testname/AppData/Local/Temp/Filecoin%20Station%20Desktop/sources/spark/main.js

Additional material I found on the internet:

https://fleexlab.blogspot.com/2016/07/what-are-those-backslash-double.html

(...) \\?\ paths, which are literal extended-length paths that you can use to access or create file system objects with weird characters in the name.

https://users.rust-lang.org/t/understanding-windows-paths/58583/2

The term "verbatim path" is used to refer to the \\?\ prefixes which allow for extended-length paths.
(...)
If you don't use \\?\ then Win32 APIs do a series of transformations to work out which path you meant.

https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file

@bajtos
Copy link
Member

bajtos commented Jul 4, 2024

@nekros05 @teo4RM4Z

I improved the log messages for this error to include additional information, I hope it will help us to understand better the problem and how to fix it.

Can you please upgrade your Station Desktop to the latest versions (1.9.0) and send us the new error messages from the module log file?

@nekros05
Copy link

nekros05 commented Jul 4, 2024

@bajtos

New log ver 1.9.0

station-modules-1720104832849.log

@bajtos
Copy link
Member

bajtos commented Jul 8, 2024

Thank you, @nekros05.

The logs confirmed my suspicion. The Windows path created from the URL of the imported module starts with C:\Users while the Windows path obtained via Rust API starts with \\?\C:\Windows.

@bajtos
Copy link
Member

bajtos commented Jul 8, 2024

Could you please install v2.0.1 and upload the new module logs?

I reworked the module sandboxing in Zinnia. Either the problem will go away, or else I should hopefully get enough the information to fix it.

@nekros05
Copy link

nekros05 commented Jul 8, 2024

@bajtos same error. New log:

station-modules-1720479195227.log

@bajtos
Copy link
Member

bajtos commented Jul 9, 2024

Cross-posting the relevant part from the module log:

Cannot canonicalize module path: El sistema no puede encontrar el archivo especificado. (os error 2).
Module URL: file:///C:/Users/Win/AppData/Local/Temp/Filecoin%20Station%20Desktop/sources/spark/main.js

@nekros05 can you please try the following steps?

  1. Stop Filecoin Station Desktop
  2. Delete everything in C:\Users\Win\AppData\Local\Temp\Filecoin Station Desktop
  3. Start Filecoin Station Desktop

@juliangruber It looks like the main module file (C:\Users\Win\AppData\Local\Temp\Filecoin Station Desktop\sources\spark\main.js) does not exist. When we call canonicalize, it fails with the error 2:

https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-

ERROR_FILE_NOT_FOUND
2 (0x2)
The system cannot find the file specified.

Do you have any idea why that could happen?

@bajtos
Copy link
Member

bajtos commented Jul 9, 2024

@nekros05
Copy link

nekros05 commented Jul 10, 2024

Hi @bajtos , it is already working, but now there is a new problem, the window goes blank after 2-3 seconds of opening it. Version 2.0.2

image

@bajtos
Copy link
Member

bajtos commented Jul 10, 2024

Hi @bajtos , it is already working, but now there is a new problem: the window goes blank after 2-3 seconds of opening it. Version 2.0.2

Please open a new GitHub issue for that in the Station Desktop repo:

https://github.com/filecoin-station/desktop/issues/new

@bajtos
Copy link
Member

bajtos commented Sep 16, 2024

The issue is still happening, see https://space-meridian.sentry.io/issues/5258168696/
There is no \\? in the path in this case.

Zinnia main loop errored ExecaError: Command failed with exit code 1: "C:\Users\ETCPOW\AppData\Local\Programs\Filecoin Station\resources\core\modules\zinnia\zinniad.exe" "spark\main.js"

[2024-09-16T12:40:17Z INFO  zinniad] Starting zinniad with config CliArgs { wallet_address: "0xF23d36AF30191346DB8e141196Ee278A883bfd3B", station_id: "302a300506032b65700321001f779dd3f98339e2cb55fdd91073cfd01501da448a10581008944999e7cd13ab", state_root: "C:\\Users\\ETCPOW\\AppData\\Local\\Filecoin Station Desktop\\modules\\zinnia", cache_root: "C:\\Users\\ETCPOW\\AppData\\Local\\Temp\\Filecoin Station Desktop\\modules\\zinnia", files: ["spark\\main.js"] }
[2024-09-16T12:40:17Z INFO  lassie] Starting Lassie Daemon
[2024-09-16T12:40:17Z INFO  lassie] Lassie Daemon is listening on port 49957
[2024-09-16T12:40:17Z INFO  zinniad] Starting module file:///C:/Users/ETCPOW/AppData/Local/Temp/Filecoin%20Station%20Desktop/sources/spark/main.js
[2024-09-16T12:40:17Z ERROR zinniad] Cannot canonicalize module path: The system cannot find the file specified. (os error 2).
    Module file path: C:\Users\ETCPOW\AppData\Local\Temp\Filecoin Station Desktop\sources\spark\main.js
    Module URL: file:///C:/Users/ETCPOW/AppData/Local/Temp/Filecoin%20Station%20Desktop/sources/spark/main.js

    at getFinalError (file:///C:/Users/ETCPOW/AppData/Local/Programs/Filecoin%20Station/resources/core/node_modules/execa/lib/return/final-error.js:6:9)
    at makeError (file:///C:/Users/ETCPOW/AppData/Local/Programs/Filecoin%20Station/resources/core/node_modules/execa/lib/return/result.js:108:16)
    at getAsyncResult (file:///C:/Users/ETCPOW/AppData/Local/Programs/Filecoin%20Station/resources/core/node_modules/execa/lib/methods/main-async.js:167:4)
    at handlePromise (file:///C:/Users/ETCPOW/AppData/Local/Programs/Filecoin%20Station/resources/core/node_modules/execa/lib/methods/main-async.js:150:17)
    at async file:///C:/Users/ETCPOW/AppData/Local/Programs/Filecoin%20Station/resources/core/lib/zinnia.js:165:9
    at async catchChildProcessExit (file:///C:/Users/ETCPOW/AppData/Local/Programs/Filecoin%20Station/resources/core/lib/zinnia.js:176:5)
    at async Promise.all (index 1)
    at async run (file:///C:/Users/ETCPOW/AppData/Local/Programs/Filecoin%20Station/resources/core/lib/zinnia.js:310:5)
    at async Promise.all (index 0)
    at async station (file:///C:/Users/ETCPOW/AppData/Local/Programs/Filecoin%20Station/resources/core/commands/station.js:113:3) 

Copy link

sentry-io bot commented Sep 16, 2024

Sentry Issue: STATION-CORE-AK4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants