code-server icon indicating copy to clipboard operation
code-server copied to clipboard

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

Open ilovebsd opened this issue 2 years ago • 12 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

OS/Web Information

  • Web Browser: Chrome
  • Local OS: Windows 10
  • Remote OS: FreeBSD 13.1-RELEASE-p2 Jails
  • Remote Architecture: amd64
  • code-server --version: 4.8.1

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?

  • [X] I cannot reproduce this in VS Code.
  • [X] I cannot reproduce this in GitHub Codespaces.

Are you accessing code-server over HTTPS?

  • [X] I am using HTTPS.

Notes

It works fine in other jails environments.

  • FreeBSD 13.1-RELEASE-p2
  • node14-14.18.1_1
  • npm-node14-6.14.8_1
  • code-server v4.0.2

ilovebsd avatar Nov 01 '22 08:11 ilovebsd

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

olegsidorkin avatar Nov 01 '22 13:11 olegsidorkin

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

Any ideas @code-asher?

jsjoeio avatar Nov 01 '22 14:11 jsjoeio

[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:

code-asher avatar Nov 01 '22 17:11 code-asher

Installed in the order below

  • pkg install node16-16.16.0 npm-node16-8.19.1 pkgconf libsecret
  • curl -fsSL https://code-server.dev/install.sh | sh

/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" }

ilovebsd avatar Nov 01 '22 21:11 ilovebsd

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

olegsidorkin avatar Nov 01 '22 22:11 olegsidorkin

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

ilovebsd avatar Nov 04 '22 08:11 ilovebsd

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.

olegsidorkin avatar Nov 07 '22 12:11 olegsidorkin

Not Work now.

ykla avatar May 21 '23 05:05 ykla

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.

  • https://github.com/microsoft/node-pty/pull/597
  • https://github.com/microsoft/vscode/pull/183027

Hope that contributes.

-RW

rowheel avatar May 21 '23 06:05 rowheel

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.

dch avatar May 22 '23 10:05 dch

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 [email protected]

rowheel avatar May 22 '23 10:05 rowheel

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.

katrinabryce avatar Sep 29 '23 11:09 katrinabryce

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.

code-asher avatar Jul 12 '24 23:07 code-asher