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

Access Denied (os error 5) #681

Closed
LelouchFR opened this issue Jan 20, 2024 · 14 comments
Closed

Access Denied (os error 5) #681

LelouchFR opened this issue Jan 20, 2024 · 14 comments
Labels
disposition:close The tagged item can probably be closed help wanted Extra attention is needed investigate More investigation is needed

Comments

@LelouchFR
Copy link

With every yew app I'm trying to serve using trunk serve I get this annoying error:

    Finished dev [unoptimized + debuginfo] target(s) in 7.12s
2024-01-20T14:34:50.637581Z  INFO fetching cargo artifacts
2024-01-20T14:34:54.981515Z  INFO calling wasm-bindgen for ocean_plastique
2024-01-20T14:34:55.674304Z  INFO rust build complete
2024-01-20T14:34:55.697563Z  INFO applying new distribution
2024-01-20T14:34:56.089222Z ERROR ❌ error
error applying built distribution

Caused by:
    0: error moving "\\\\?\\D:\\Bump\\PROG\\WEB\\rust\\Yew\\ocean_plastique\\dist\\.stage\\svg" to "
\\\\?\\D:\\Bump\\PROG\\WEB\\rust\\Yew\\ocean_plastique\\dist\\svg"
    1: Accès refusé. (os error 5)

image

I beg for a simple answer for fixing this problem and not a simple read the doc answer plz, been stuck for a long time and has already browsed on everything on the internet available for this answer and nothing worked.

Setup:

  • Normal rust install from their website (cargo 1.75.0 (1d8b05cdd 2023-11-20))
  • Trunk installed using cargo install --locked trunk (trunk 0.18.6)
  • Windows ver 10.0.19045 Build 19045
  • No Anti-Virus (Windows Defender off)
  • Get-ExecutionPolicy -List:
        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser    RemoteSigned
 LocalMachine    Unrestricted
  • Get-AppLockerPolicy -Effective:
Version RuleCollections RuleCollectionTypes
------- --------------- -------------------
      1 {}              {}
  • running powershell or cmd as administrator or normal
  • Everything in the exclusion of Windows Defender (even if down)
@ctron ctron added help wanted Extra attention is needed investigate More investigation is needed labels Jan 22, 2024
@ctron
Copy link
Collaborator

ctron commented Jan 22, 2024

Hard to tell for me (as I am not using Windows). It seems it works for others, so some more investigation (help) is needed with this one.

One reason for Windows to report access denied (IIRC) can also be that the file is already open by another process.

@gjersvik
Copy link

gjersvik commented Jan 23, 2024

The problem is that \\\\?\\D:\\... is not a valid windows path. "std::fs::canonicalize" gives a path on windows that is unusable and i have often had to do some post processing to get something that the rust fs api will accept as a path.

Is there a common place where trunk do path resolution? If so I can create a quick fix.

@ctron
Copy link
Collaborator

ctron commented Jan 23, 2024

That's a problem 🙄 … glad one could still use A: and B:

I don't recall there being a single spot. Here are some common functions around that topic: https://github.com/trunk-rs/trunk/blob/main/src/common.rs

But I also know that fs::canonicalize is used quite frequently, and I am not sure "why", but also would not want to make rash changes on those calls.

@ctron
Copy link
Collaborator

ctron commented Jan 23, 2024

I assume you're talking about this one: rust-lang/rust#42869

@gjersvik
Copy link

Yes I believe that to be the underlying issue. In the pass I have gotten the same access denied when try to put canonical path into a tool that do not support it. My fix in was 2 string replace one to remove the \\\\?\\ and another to turn \\ into \ To get a more sane looking path. For the tools that du not understand the new windows monstrosity.

@ctron
Copy link
Collaborator

ctron commented Jan 23, 2024

Well that path (and the current issue) is using tokio::fs::rename from what I understand. Does that suffer from the same issue?

@gjersvik
Copy link

Just did a quick test. tokio::fs::rename handle the windows paths just fine. Both with files and directories.

#[tokio::main]
async fn main() {
    let from = tokio::fs::canonicalize("./test").await.unwrap();
    let to = "./test2";
    println!("rename from {from:?} to {to:?}");
    tokio::fs::rename(from, to).await.unwrap();
}

Output:
rename from "\\\\?\\C:\\dev\\playground\\test" to "./test2" No errors from unwrap

@ctron
Copy link
Collaborator

ctron commented Jan 23, 2024

Thanks for testing! So we can rule out that cause, right?

@gjersvik
Copy link

Yes sadly have my own problem that took me to this issue. But can't look into that before until this evening. Based on this discussion windows + canonicalize + commands = danger.

@gjersvik
Copy link

gjersvik commented Jan 23, 2024

I did get a Access Denied on windows trying to create the ./target dir. But not for target build there I got a lot of random garbage build error. Option not defined that kind of thing. Finally found my issue: Forgot to run: rustup target add wasm32-unknown-unknown. And now trunk is a happy camper.

@LelouchFR
Copy link
Author

I did get a Access Denied on windows trying to create the ./target dir. But not for target build there I got a lot of random garbage build error. Option not defined that kind of thing. Finally found my issue: Forgot to run: rustup target add wasm32-unknown-unknown. And now trunk is a happy camper.

This is not the problem, because I have it up to date I already had it installed but still get this error somehow...
I understand that the problem can come from the path, but is there a fix possible in the upcomming version of trunk ? (Instead of, from what I understood, to change something myself in the trunk code (sorry I'm new to rust so, kinda hard to catch up to everything...))

@ctron
Copy link
Collaborator

ctron commented Jan 24, 2024

is there a fix possible in the upcomming version of trunk ?

I think right now the problem is not understood. So that question is: what is broken? … I do understand it doesn't work for you, but others don't seem to have this issue. So I wouldn't rule out some issue/difference with your local system. And I do know that this can be frustrating, but also try to understand that without being able to reproduce, it's hard to get an understanding of the problem.

Maybe switching to WSL helps?

@lukethacoder
Copy link

Ran into a similar issue trying to give Leptos a crack for the first time.

Might sound silly, but manually creating the /target folder in your project root seemed to solve the issue? Must not have access to create the folder in the project 🤷‍♀️

@ctron ctron added the disposition:close The tagged item can probably be closed label Mar 12, 2024
@ctron
Copy link
Collaborator

ctron commented May 3, 2024

Looks like we can close the issue. I am not sure what trunk could do better.

@ctron ctron closed this as completed May 3, 2024
JurrianFahner added a commit to JurrianFahner/yew that referenced this issue Aug 3, 2024
By adding these commands to the instructions, the getting started guide is more failsafe. It looks like I have this error: trunk-rs/trunk#681
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition:close The tagged item can probably be closed help wanted Extra attention is needed investigate More investigation is needed
Projects
None yet
Development

No branches or pull requests

4 participants