-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Leading slash with env::current_dir() in Windows #20559
Comments
I have looked around and found one peculiarity:
What if we try |
Nothing changes with v23 and windows instead of mingw. |
Thank you, good to know. One other thing I was pointed at is zed/crates/extension_host/src/wasm_host.rs Lines 313 to 315 in 55cd99c
and this: zed/crates/extension_host/src/wasm_host.rs Lines 161 to 183 in 55cd99c
could we debug and check what kind of paths dwell there? Or I can check this tomorrow when I'm back to my Win machine. |
To answer my question, seems that we're doing fine here:
for a patch diff --git a/crates/extension_host/src/wasm_host.rs b/crates/extension_host/src/wasm_host.rs
index bd66a31a27..e28245d037 100644
--- a/crates/extension_host/src/wasm_host.rs
+++ b/crates/extension_host/src/wasm_host.rs
@@ -255,7 +255,7 @@ impl WasmHost {
Ok(WasmExtension {
manifest: manifest.clone(),
- work_dir: this.work_dir.clone().into(),
+ work_dir: dbg!(this.work_dir.clone()).into(),
tx,
zed_api_version,
})
@@ -265,7 +265,7 @@ impl WasmHost {
async fn build_wasi_ctx(&self, manifest: &Arc<ExtensionManifest>) -> Result<wasi::WasiCtx> {
let extension_work_dir = self.work_dir.join(manifest.id.as_ref());
self.fs
- .create_dir(&extension_work_dir)
+ .create_dir(dbg!(&extension_work_dir))
.await
.context("failed to create extension work dir")?; I still find it very suspicious that / -prefixed paths look exactly how my MINGW terminal does this: Given that using the upgraded version of the SDK did not help and it was mingw-only version before, I lean to the fact that this is a bug in wasi. The next step we'd better do then, is creating a minimal examle to repro this, and submitting this to their repo. |
Would you like to test the windows v23 SDK yourself? In case I have done something wrong with it. Before we even file an issue to them. |
I did retest it by changing all SDK versions in the code and recompiling the html plugin in dev mode with it, so not sure we are missing anything. |
The working directory has been changed using the PWD environment variable here, but this variable cannot be accessed under Windows, which may be related to this issue. zed/crates/extension_api/src/extension_api.rs Line 169 in 6cba467
|
It's not that, apparently, if I change the extension as diff --git a/crates/extension_api/src/extension_api.rs b/crates/extension_api/src/extension_api.rs
index 4bb1229538..7d7f17b1b3 100644
--- a/crates/extension_api/src/extension_api.rs
+++ b/crates/extension_api/src/extension_api.rs
@@ -166,6 +166,8 @@ macro_rules! register_extension {
($extension_type:ty) => {
#[export_name = "init-extension"]
pub extern "C" fn __init_extension() {
+ let a = std::env::var("PWD");
+ eprintln!("??????????????????? {:?}", a);
std::env::set_current_dir(std::env::var("PWD").unwrap()).unwrap();
zed_extension_api::register_extension(|| {
Box::new(<$extension_type as zed_extension_api::Extension>::new())
diff --git a/extensions/html/Cargo.toml b/extensions/html/Cargo.toml
index e8f8a741bd..e9ee29f203 100644
--- a/extensions/html/Cargo.toml
+++ b/extensions/html/Cargo.toml
@@ -13,4 +13,4 @@ path = "src/html.rs"
crate-type = ["cdylib"]
[dependencies]
-zed_extension_api = "0.1.0"
+zed_extension_api = { path = "../../crates/extension_api" } and install the html extension as a dev one, I see
|
I think the issue lies with You can test this with your current modifications by making the following changes to your code: macro_rules! register_extension {
($extension_type:ty) => {
#[export_name = "init-extension"]
pub extern "C" fn __init_extension() {
let a = std::env::var("PWD");
eprintln!("PWD: {:?}", a);
std::env::set_current_dir(std::env::var("PWD").unwrap()).unwrap();
eprintln!("Get: {:?}", std::env::current_dir()); // Add this line
zed_extension_api::register_extension(|| {
Box::new(<$extension_type as zed_extension_api::Extension>::new()) Which prints something like: PWD: Ok("C:\\Users\\awpc\\AppData\\Local\\Zed\\extensions\\work\\html")
Get: Ok("/C:\\Users\\awpc\\AppData\\Local\\Zed\\extensions\\work\\html") And under WASI, |
I believe the only thing we can do is to remove the leading slash from the string in the Windows environment. :( |
I think it is only way we can do.
…________________________________
发件人: Ninnana ***@***.***>
发送时间: 2024年12月28日 2:49
收件人: zed-industries/zed ***@***.***>
抄送: Yakira ***@***.***>; Comment ***@***.***>
主题: Re: [zed-industries/zed] Leading slash with env::current_dir() in Windows (Issue #20559)
I believe the only thing we can do is to remove the leading slash from the string in the Windows environment. :(
―
Reply to this email directly, view it on GitHub<#20559 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALL6V3M6DLEB3MYSV5V26UL2HWOKTAVCNFSM6AAAAABRU7OCGOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRTHE2DQOJUGE>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Why did I go to check Wasmtime? It's because wasm runs within Wasmtime, and WASI is an interface that provides wasm with the ability to access files, but does not have the capability to run wasm. |
Now we have two options: one is to choose another wasm runtime, and the other is to simply remove the leading slash. However, the first option is too complex, involving too many modules. Therefore, we can only choose the second option. |
i create a pull request on zed-extensions/vue#9. I used regex instead of |
|
I'm working on it. |
Check for existing issues
Describe the bug / provide steps to reproduce it
The issue is related to LSPs not spinning up due to a message like this one:
or this one:
The problem is related to the WASM runtime in which the extensions run. The
env::current_dir()
is abstracted away from the base platform in which Zed is running. You can check this withenv::constants::OS
which returns an empty string.env::current_dir()
returns this path:"/C:\\Users\\alvga\\AppData\\Local\\Zed\\extensions\\work\\astro_1/node_modules/@astrojs/language-server/bin/nodeServer.js"
. You will see a leading forward slash which then is passed to thezed::Command
and interprets it as some disk, and ultimately having the first presented log.This may not only impact extensions but maybe other crates as well.
Environment
Zed: v0.162.0 (Zed Dev 4ca1837)
OS: Windows 10.0.22631
Memory: 47.9 GiB
Architecture: x86_64
GPU: NVIDIA GeForce RTX 3060 || NVIDIA || 565.90
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your Zed.log file to this issue.
No response
The text was updated successfully, but these errors were encountered: