zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
34.48k stars 1.71k forks source link

Windows : try to open zed code from command line , zed crash #10849

Closed E834159672 closed 1 week ago

E834159672 commented 3 weeks ago

Check for existing issues

Describe the bug / provide steps to reproduce it

D:\src\rust\zed>target\debug\zed.exe d:\src\rust\zed\
[2024-04-22T21:39:52+08:00 ERROR util] crates\settings\src\keymap_file.rs:89: invalid binding value for keystroke ctrl-alt-shift-down, context Some("Editor")

Caused by:
    no action type registered for editor::DuplicateLine
[2024-04-22T21:39:52+08:00 ERROR util] crates\settings\src\keymap_file.rs:89: invalid binding value for keystroke ctrl-alt-shift-up, context Some("Editor")

Caused by:
    no action type registered for editor::DuplicateLine
[2024-04-22T21:39:52+08:00 ERROR util] crates\settings\src\keymap_file.rs:89: invalid binding value for keystroke escape, context Some("ChatPanel > MessageEditor")

Caused by:
    no action type registered for chat_panel::CloseReplyPreview
[2024-04-22T21:39:53+08:00 ERROR util] crates\zed\src\zed.rs:636: EOF while parsing a value at line 1 column 0
Thread "" panicked with "Watching root is probably not what you want" at crates\fs\src/fs.rs:426:22
   0: backtrace::backtrace::dbghelp::trace
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\backtrace-0.3.69\src\backtrace\dbghelp.rs:98
   1: backtrace::backtrace::trace_unsynchronized
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\backtrace-0.3.69\src\backtrace\mod.rs:66
   2: backtrace::backtrace::trace
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\backtrace-0.3.69\src\backtrace\mod.rs:53
   3: backtrace::capture::Backtrace::create
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\backtrace-0.3.69\src\capture.rs:176
   4: backtrace::capture::Backtrace::new
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\backtrace-0.3.69\src\capture.rs:140
   5: Zed::init_panic_hook::closure$0
             at crates\zed\src\main.rs:739
   6: alloc::boxed::impl$49::call
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\alloc\src\boxed.rs:2029
   7: std::panicking::rust_panic_with_hook
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\std\src\panicking.rs:785
   8: std::panicking::begin_panic_handler::closure$0
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\std\src\panicking.rs:659
   9: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\std\src\sys_common\backtrace.rs:171
  10: std::panicking::begin_panic_handler
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\std\src\panicking.rs:647
  11: core::panicking::panic_fmt
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\core\src\panicking.rs:72
  12: core::panicking::panic_display
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\core\src\panicking.rs:196
  13: core::panicking::panic_str
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\core\src\panicking.rs:171
  14: core::option::expect_failed
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\core\src\option.rs:1988
  15: core::option::Option::expect >
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\library\core\src\option.rs:894
  16: fs::impl$17::watch::async_block$0
             at crates\fs\src\fs.rs:425
  17: core::future::future::impl$1::poll > >,core::marker::
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\library\core\src\future\future.rs:124
  18: worktree::start_background_scan_tasks::async_block$0
             at crates\worktree\src\worktree.rs:679
  19: core::future::future::impl$1::poll > >,core::marker::Send>,alloc::alloc::Global> >
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\library\core\src\future\future.rs:124
  20: async_task::raw::RawTask::run > >,core::marker::Send>,alloc::alloc::Global> >,tuple$<>,gpui::executor::impl$5::spawn_internal::closure_env$0 >,tuple$<> >
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\async-task-4.7.0\src\raw.rs:557
  21: async_task::runnable::Runnable::run >
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\async-task-4.7.0\src\runnable.rs:781
  22: gpui::platform::windows::dispatcher::threadpool_runner
             at crates\gpui\src\platform\windows\dispatcher.rs:139
  23: TpCallbackMayRunLong
  24: TpCallbackMayRunLong
  25: BaseThreadInitThunk
  26: RtlUserThreadStart

code version :

D:\src\rust\zed>git log
commit 615de381dabd3501ff8863a201c2df1be1b70b46 (HEAD -> main, origin/main, origin/HEAD)

Environment

windows 11

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

DissolveDZN commented 3 weeks ago

try deleting your zed config file in ~\Appdata\Roaming\Zed\keymap.json and settings.json happened to me too once but i can open it fine via command line, also tried on win11

E834159672 commented 3 weeks ago

try deleting your zed config file in ~\Appdata\Roaming\Zed\keymap.json and settings.json happened to me too once but i can open it fine via command line, also tried on win11

i rename the ~\Appdata\Roaming\Zed dir to zed1, then run , zed.exe d:\src\rust\zed,

D:\src\rust\zed\target\debug>zed.exe d:\src\rust\zed
[2024-04-23T11:34:01+08:00 ERROR util] crates\settings\src\settings_file.rs:76: EOF while parsing a value at line 1 column 0
[2024-04-23T11:34:01+08:00 ERROR util] crates\settings\src\keymap_file.rs:89: invalid binding value for keystroke ctrl-alt-shift-down, context Some("Editor")

Caused by:
    no action type registered for editor::DuplicateLine
[2024-04-23T11:34:01+08:00 ERROR util] crates\settings\src\keymap_file.rs:89: invalid binding value for keystroke ctrl-alt-shift-up, context Some("Editor")

Caused by:
    no action type registered for editor::DuplicateLine
[2024-04-23T11:34:01+08:00 ERROR util] crates\settings\src\keymap_file.rs:89: invalid binding value for keystroke escape, context Some("ChatPanel > MessageEditor")

Caused by:
    no action type registered for chat_panel::CloseReplyPreview
[2024-04-23T11:34:03+08:00 ERROR util] crates\zed\src\zed.rs:636: EOF while parsing a value at line 1 column 0
[2024-04-23T11:34:03+08:00 ERROR util] crates\zed\src/main.rs:835: The system cannot find the path specified. (os error 3)
[2024-04-23T11:34:03+08:00 ERROR util] crates\zed\src/main.rs:1143: Access is denied. (os error 5)
[2024-04-23T11:34:03+08:00 ERROR util] crates\workspace\src/workspace.rs:951: Error in last_window, select_row_bound expected single row result but found none for: SELECT
  display,
  window_state,
  window_x,
  window_y,
  window_width,
  window_height,
  fullscreen
FROM
  workspaces
WHERE
  workspace_location IS NOT NULL
ORDER BY
  timestamp DESC
LIMIT
  1
Thread "" panicked with "Watching root is probably not what you want" at crates\fs\src/fs.rs:426:22
   0: backtrace::backtrace::dbghelp::trace
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\backtrace-0.3.69\src\backtrace\dbghelp.rs:98
   1: backtrace::backtrace::trace_unsynchronized
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\backtrace-0.3.69\src\backtrace\mod.rs:66
   2: backtrace::backtrace::trace
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\backtrace-0.3.69\src\backtrace\mod.rs:53
   3: backtrace::capture::Backtrace::create
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\backtrace-0.3.69\src\capture.rs:176
   4: backtrace::capture::Backtrace::new
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\backtrace-0.3.69\src\capture.rs:140
   5: Zed::init_panic_hook::closure$0
             at D:\src\rust\zed\crates\zed\src\main.rs:739
   6: alloc::boxed::impl$49::call
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\alloc\src\boxed.rs:2029
   7: std::panicking::rust_panic_with_hook
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\std\src\panicking.rs:785
   8: std::panicking::begin_panic_handler::closure$0
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\std\src\panicking.rs:659
   9: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\std\src\sys_common\backtrace.rs:171
  10: std::panicking::begin_panic_handler
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\std\src\panicking.rs:647
  11: core::panicking::panic_fmt
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\core\src\panicking.rs:72
  12: core::panicking::panic_display
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\core\src\panicking.rs:196
  13: core::panicking::panic_str
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\core\src\panicking.rs:171
  14: core::option::expect_failed
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library\core\src\option.rs:1988
  15: core::option::Option::expect >
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\library\core\src\option.rs:894
  16: fs::impl$17::watch::async_block$0
             at D:\src\rust\zed\crates\fs\src\fs.rs:425
  17: core::future::future::impl$1::poll > >,core::marker::
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\library\core\src\future\future.rs:124
  18: worktree::start_background_scan_tasks::async_block$0
             at D:\src\rust\zed\crates\worktree\src\worktree.rs:679
  19: core::future::future::impl$1::poll > >,core::marker::Send>,alloc::alloc::Global> >
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\library\core\src\future\future.rs:124
  20: async_task::raw::RawTask::run > >,core::marker::Send>,alloc::alloc::Global> >,tuple$<>,gpui::executor::impl$5::spawn_internal::closure_env$0 >,tuple$<> >
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\async-task-4.7.0\src\raw.rs:557
  21: async_task::runnable::Runnable::run >
             at D:\packages\cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\async-task-4.7.0\src\runnable.rs:781
  22: gpui::platform::windows::dispatcher::threadpool_runner
             at D:\src\rust\zed\crates\gpui\src\platform\windows\dispatcher.rs:139
  23: TpCallbackMayRunLong
  24: TpCallbackMayRunLong
  25: BaseThreadInitThunk
  26: RtlUserThreadStart

D:\src\rust\zed\target\debug>
DissolveDZN commented 3 weeks ago

oh then it's probably something else

DissolveDZN commented 3 weeks ago

try building release mode, that worked for me, just add the --release flag

E834159672 commented 3 weeks ago

try building release mode, that worked for me, just add the --release flag

in release mode, i found the problem ,then to view the log , i build it in debug mode .

sorry for my poor English. many thanks .

tommy141x commented 2 weeks ago

I believe I am having the same issue as well, something changed within the last 2 weeks that causes Zed to panic when trying to open a file, I can open Zed.exe directly but I cannot open a file or use "Open With Zed".

Here is my log: https://pastebin.com/raw/0s9Xm2j1

tommy141x commented 2 weeks ago

I've never coded with Rust so this is as far as I could debug it, but when the workspace.rs calls the create_local_worktree function, the abs_paths parameter passed to it is the root directory. This root path, is then passed to project.rs which creates a new worktree.rs which calls start_background_scan_tasks which calls the watch function inside fs.rs which does a check for if the path provided is the root directory which then causes a panic.

I was unable to figure out how workspace.rs gets the path that it somehow provides to itself when creating Workspace::new_local.

KairuDeibisu commented 2 weeks ago

I've been learning rust. I'm going to take a crack at resolving the issue. I'm not at my computer at the moment so I'm going to write down my initial guess before I forget until I can get to a computer.

Matching on an enum can be an anti-pattern when using wild card, because adding a new enum should give you an error, until you fix the match to handle the new case, but the error is hidden by the wild card.

When I get to a computer, I'll look into it.

Screenshot_20240504_222516_Chrome

Note: crates/settings/src/keymap_file.rs 65.

tommy141x commented 2 weeks ago

I hadn't noticed but there is a PR #11119 in progress which should fix this issue, the weird part is that I wasn't having this issue until about 2 weeks ago, so I would believe if it was broken by a commit that it can't be too far from a working state.

tommy141x commented 1 week ago

PR #11119 seems to have fixed this for me! 🎉

E834159672 commented 1 week ago

the latest version has fixed this bug for me ! so maybe we should close this issue.

E834159672 commented 1 week ago

many thanks to everyone !