zed icon indicating copy to clipboard operation
zed copied to clipboard

Can't install TSX language server

Open Iovans opened this issue 1 year ago • 5 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

i can't use tsx autocomplete because it keeps getting error during download,i tried reinstall zed but dont work

Environment

Zed: v0.119.4 (Zed Preview) OS: macOS 14.2.1 Memory: 8 GiB Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

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

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

Language server error: TSX

failed to execute npm install subcommand: stdout: "" stderr: "npm ERR! code EACCES\nnpm ERR! syscall rename\nnpm ERR! path /Users/manueliovane/node_modules/download\nnpm ERR! dest /Users/manueliovane/node_modules/.download-Eq5U6GUS\nnpm ERR! errno -13\nnpm ERR! Error: EACCES: permission denied, rename '/Users/manueliovane/node_modules/download' -> '/Users/manueliovane/node_modules/.download-Eq5U6GUS'\nnpm ERR! [Error: EACCES: permission denied, rename '/Users/manueliovane/node_modules/download' -> '/Users/manueliovane/node_modules/.download-Eq5U6GUS'] {\nnpm ERR! errno: -13,\nnpm ERR! code: 'EACCES',\nnpm ERR! syscall: 'rename',\nnpm ERR! path: '/Users/manueliovane/node_modules/download',\nnpm ERR! dest: '/Users/manueliovane/node_modules/.download-Eq5U6GUS'\nnpm ERR! }\nnpm ERR! \nnpm ERR! The operation was rejected by your operating system.\nnpm ERR! It is likely you do not have the permissions to access this file as the current user\nnpm ERR! \nnpm ERR! If you believe this might be a permissions issue, please double-check the\nnpm ERR! permissions of the file and its containing directories, or try running\nnpm ERR! the command again as root/Administrator.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /Users/manueliovane/Library/Application Support/Zed/node/node-v18.15.0-darwin-x64/cache/_logs/2024-01-08T22_59_42_849Z-debug-0.log\n"

Iovans avatar Jan 08 '24 23:01 Iovans

I was having the same issue, but I could fix it!

Have you tried one of both? https://github.com/zed-industries/zed/issues/4628#issuecomment-1908628110 https://github.com/zed-industries/zed/issues/4628#issuecomment-1908628375

fm1randa avatar Jan 26 '24 19:01 fm1randa

I didnt tried that,i tried another alternative but didnt work anyway It works for you?

Iovans avatar Jan 26 '24 19:01 Iovans

Also got this error when opening a fresh react native project. Will try attached solutions thanks for documenting this.

Dax911 avatar Jan 29 '24 19:01 Dax911

Best guess for fixing this issue appears to be in the construction of the Command in the run_npm_subcommand method of the RealNodeRuntime implementation. Specifically, the npm_file path is being passed as an argument to the node_binary, resulting in the nnpm instead of npm in the command.

Here's the relevant portion of the code:

let node_binary = installation_path.join("bin/node");
let npm_file = installation_path.join("bin/npm");

// ...

let mut command = Command::new(node_binary);
command.env_clear();
command.env("PATH", env_path);
command.arg(npm_file).arg(subcommand);
command.args(["--cache".into(), installation_path.join("cache")]);
// ...

To fix this, you should change the command.arg(npm_file) line to command.arg(&npm_file) to ensure that npm_file is treated as a separate argument. Here's the corrected code:

let node_binary = installation_path.join("bin/node");
let npm_file = installation_path.join("bin/npm");

// ...

let mut command = Command::new(node_binary);
command.env_clear();
command.env("PATH", env_path);
command.arg(&npm_file).arg(subcommand); // Fix here
command.args(["--cache".into(), installation_path.join("cache")]);
// ...

This change ensures that the npm_file path is passed correctly as a separate argument, and it should resolve the issue of nnpm being parsed instead of npm.

Edit: will try for a PR after lunch

Dax911 avatar Jan 29 '24 19:01 Dax911

Best guess for fixing this issue appears to be in the construction of the Command in the run_npm_subcommand method of the RealNodeRuntime implementation. Specifically, the npm_file path is being passed as an argument to the node_binary, resulting in the nnpm instead of npm in the command.

The only nnpm I'm seeing in this issue is the \nnpm, which is just the newlines in the npm logs.

maxdeviant avatar Jan 29 '24 20:01 maxdeviant

I'm pretty sure this is a duplicate of https://github.com/zed-industries/zed/issues/5085 where we seem to end up with the directory we install to having incorrect permissions, preventing us from installing servers

ForLoveOfCats avatar Feb 05 '24 19:02 ForLoveOfCats