coder / code-server

VS Code in the browser
https://coder.com
MIT License
68.35k stars 5.6k forks source link

[Bug]: No working Terminal on FreeBSD 13.1-RELEASE-p2 #5741

Closed ilovebsd closed 3 months ago

ilovebsd commented 2 years ago

Is there an existing issue for this?

OS/Web Information

Steps to Reproduce

  1. open code-server on Chrome
  2. New Notification "The connection to the terminal's pty host process is unresponsive, the terminals may stop working."
  3. Repeated "Restart pty host"

Expected

pty host must operate normally

Actual

Terminal is not working.

Logs

[17:00:43] ptyHost was unable to resolve shell environment Error: Unable to resolve your shell environment: Unexpected exit code from spawned shell (code 1, signal null) at /usr/local/lib/node_modules/code-server/lib/vscode/out/vs/server/node/server.main.js:92:2607 at async /usr/local/lib/node_modules/code-server/lib/vscode/out/vs/server/node/server.main.js:67:23805 [IPC Library: Pty Host] The factory function of "vs/platform/terminal/node/ptyHostMain" has thrown an exception [IPC Library: Pty Host] Error: Platform not supported at E (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/platform/terminal/node/ptyHostMain.js:19:811) at y (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/platform/terminal/node/ptyHostMain.js:19:110) at new E (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/platform/terminal/node/ptyHostMain.js:19:1504) at Object. (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/platform/terminal/node/ptyHostMain.js:27:17502) at Function.s._safeInvokeFunction (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:1337) at Function.s._invokeFactory (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:1522) at s.complete (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:1801) at s._onModuleComplete (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:1112) at s._onModuleComplete (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:1358) at s._onModuleComplete (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:1358) at s._onModuleComplete (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:1358) at s._onModuleComplete (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:1358) at s._resolve (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:510) at s.defineModule (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:6066) at n (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10527) at Object.R (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:6036) at Function.s._safeInvokeFunction (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:1337) at Function.s._invokeFactory (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:1522) at s.complete (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:1801) at s._onModuleComplete (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:1112) at s._onModuleComplete (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:1358) at s._resolve (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:510) at s.defineModule (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:6066) at y (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:1825) at h (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2554) at Object. (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/platform/terminal/node/ptyHostMain.nls.js:3:61) at e._createAndEvalScript (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2598) at /usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2237 at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) [IPC Library: Pty Host] Here are the modules that depend on it: [IPC Library: Pty Host]% [ '===anonymous1===' ] [17:00:43] [192.168.0.104][5ee7cc5d][ExtensionHostConnection] Unknown reconnection token (never seen). [17:00:43] [192.168.0.104][eb8a76c1][ManagementConnection] Unknown reconnection token (never seen). [IPC Library: Pty Host] Unknown channel: heartbeat [IPC Library: Pty Host] Unknown channel: log [IPC Library: Pty Host] Unknown channel: ptyHost [IPC Library: Pty Host] Unknown channel: ptyHost [IPC Library: Pty Host] Unknown channel: ptyHost [IPC Library: Pty Host] Unknown channel: ptyHost [IPC Library: Pty Host] Unknown channel: ptyHost [IPC Library: Pty Host] Unknown channel: ptyHost [IPC Library: Pty Host] Unknown channel: ptyHost

Screenshot/Video

bug

Does this issue happen in VS Code or GitHub Codespaces?

Are you accessing code-server over HTTPS?

Notes

It works fine in other jails environments.

olegsidorkin commented 2 years ago

The same thing happens with code-server 4.8.1/ node16 / FreeeBSD 13.

jsjoeio commented 2 years ago

Hmm I haven't used freebsd so I'm not sure what could be happening here.

Any ideas @code-asher?

code-asher commented 2 years ago

[IPC Library: Pty Host] Error: Platform not supported

Was code-server installed via npm? If so then I am not sure why node-pty is saying the platform is not supported. :thinking:

ilovebsd commented 2 years ago

Installed in the order below

/usr/local/lib/node_modules/code-server/lib/vscode/node_modules/node-pty/package.json { "name": "node-pty", "description": "Fork pseudoterminals in Node.JS", "author": { "name": "Microsoft Corporation" }, "version": "0.11.0-beta11", "license": "MIT", "main": "./lib/index.js", "types": "./typings/node-pty.d.ts", "repository": { "type": "git", "url": "git://github.com/microsoft/node-pty.git" }, "files": [ "binding.gyp", "lib/", "scripts/", "src/", "deps/", "typings/" ], "homepage": "https://github.com/microsoft/node-pty", "bugs": { "url": "https://github.com/microsoft/node-pty/issues" }, "keywords": [ "pty", "tty", "terminal", "pseudoterminal", "forkpty", "openpty" ], "scripts": { "build": "tsc -b ./src/tsconfig.json", "watch": "tsc -b -w ./src/tsconfig.json", "lint": "eslint -c .eslintrc.js --ext .ts src/", "install": "node scripts/install.js", "postinstall": "node scripts/post-install.js", "test": "cross-env NODE_ENV=test mocha -R spec --exit lib/*.test.js", "posttest": "npm run lint", "prepare": "npm run build", "prepublishOnly": "npm run build" }, "dependencies": { "nan": "^2.14.0" }, "devDependencies": { "@types/mocha": "^7.0.2", "@types/node": "12", "@typescript-eslint/eslint-plugin": "^2.27.0", "@typescript-eslint/parser": "^2.27.0", "cross-env": "^5.1.4", "eslint": "^6.8.0", "mocha": "^7.1.1", "ps-list": "^6.0.0", "typescript": "^3.8.3" }

olegsidorkin commented 2 years ago

After looking at compiled JS, i think it's here: https://github.com/microsoft/vscode/blob/9db57e76e9f16f552203585a394e50cf0f7a84a7/src/vs/platform/environment/node/userDataPath.js#L98

However setting --user-data-dir ~/.local/share/code-server didn't help. Electron is 18.3.11

ilovebsd commented 1 year ago

I changed the default shell to bash or zsh and solved the problem by referring to the link below. Thank you @kawanakaiku

https://github.com/coder/code-server/issues/5496#issuecomment-1240839804

olegsidorkin commented 1 year ago

I changed the default shell to bash or zsh and solved the problem by referring to the link below. Thank you @kawanakaiku

#5496 (comment)

Yes, this helped. Terminal started to work after patching with sed.

ykla commented 1 year ago

Not Work now.

rowheel commented 1 year ago

Not Work now.

Didn't work indeed.

However, it seems like an upstream issue so pointing our fingers to coder/code-server may not work as intended.

Meanwhile, I just fired some PRs at microsoft/node-pty and microsoft/vscode to see if they can give code reviews and possibly approve those fixes.

Hope that contributes.

-RW

dch commented 1 year ago

thanks! @rowheel do you have a branch somewhere including all your fixes? If this works atm I'd like to get it into ports proper.

rowheel commented 1 year ago

thanks! @rowheel do you have a branch somewhere including all your fixes? If this works atm I'd like to get it into ports proper.

Hi @dch,

The fix for node-pty has been accepted by Microsoft. (Thanks M$!)

The fix for vscode is, however, still unanswered. If you want to see what's changed you can click on the PR link above. It's not a complicated fix to be honest.

-RW

Update: The issue found in node-pty was a hard block that directly causes compile error, which in turn directly lead to dependency loss under lib/vscode

The issue found in vscode, however, can be worked around by setting an environment variable called VSCODE_APPDATA

Update: An old code-server release v4.11.0 is known to work on FreeBSD 13.2.

At the release of coder-server v4.11.0 aka VS Code v1.76, the poison in node-pty has not yet been introduced into the trunk so the compile was good.

Personally recommending FreeBSD users to stick to that version until further official code-server release.

# yarn global add code-server@v4.11.0
katrinabryce commented 1 year ago

thanks! @rowheel do you have a branch somewhere including all your fixes? If this works atm I'd like to get it into ports proper.

My process for installing it is:

npm install -g code-server --unsafe-perm
cd /usr/local/lib/node_modules/code-server/
npm install --unsafe-perm
sed -i -e 's|switch(process.platform)|switch("linux")|' /usr/local/lib/node_modules/code-server/lib/vscode/out/vs/platform/terminal/node/ptyHostMain.js

The patch is based on the comment referred to further up this thread. A lot of dependencies don't install first time round, hence the second installation round. Works for 4.16.1. 4.17.0 isn't on npm yet.

code-asher commented 3 months ago

Closing for now, but if this is still a problem and there is something we can fix on code-server's end, let me know.