You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: terminal not working when your web base_path is not / #5321
code-server --version: 4.5.0 02b9d7e with Code 1.68.1
Steps to Reproduce
use k8s ingress, set code server base path to /ide/
open ${your-code-server-host}/ide/
ctrl + J open terminal
Expected
show terminal
Actual
No terminal created.
open chrome dev Terminal, you will see some errors like this:
Failed to load resource: the server responded with a status of 503 (Service Unavailable)
/stable-30d9c6cd9483b2cc586687151bcbcd635f373630/static/out/vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.win.js:1
but the root path of ide is /ide/ , not /
Logs
No response
Screenshot/Video
No response
Does this issue happen in VS Code or GitHub Codespaces?
I cannot reproduce this in VS Code.
I cannot reproduce this in GitHub Codespaces.
Are you accessing code-server over HTTPS?
I am using HTTPS.
Notes
If your root path is /, terminal will open correctly.
changed the title [-][Bug]: terminal not working when your root_path is not /[/-][+][Bug]: terminal not working when your web base_path is not /[/+]on Jul 4, 2022
@jsjoeio The changes regarding baseUrl when comparing /opt/code-server/lib/vscode/out/vs/code/browser/workbench/workbench.html from code-server v4.4.0 to v4.5.0:
Hi all - thank you for the reports and the details! We had all last week off for the holidays so I'm just now seeing this. @code-asher is out until Thursday. I'm going to start investigating this today.
Hoping I should be able to easily reproduce with Caddy
Whenever issues like this happen, it's usually related to a VS Code upgrade which is the most brittle part of the codebase.
@benz0li left a helpful diff here to show any changes related to baseUrl.
I'm going to look at the commits for the 1.68 upgrade to see what we documented about the change.
Nothing stands out in particular there. It seems like the baseUrl is wrong for anything in /static/node_modules/ looking at @aghontpi. I see those upstream here:
The only difference is using window.location in the call to new URL instead of window.location.origin.
Strangely, the MDN docs say the second argument to new URL should be base: stringhere.
This is in an HTML file inside a <script /> tag so I am guessing that's why we don't have any TypeScript errors. I'm going to try making that change and run code-server locally with yarn watch to see if that solves it.
Actually...that may not be accurate.
In particular, you can use an existing URL object for either argument, and it will stringify to the object's href property.
So this means it went from using the origin (string we passed) to using the href which means it's a different value:
thinking out loud...feels like we have logic in place to make sure WORKBENCH_WEB_BASE_URL supports a relative root and then this line "reverts" that back to assuming code-server is at the root:
const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location.origin).toString();
oddly enough, workbench.html and workbench-dev.html do not create baseUrl the same.
Well, when I change workbench-dev.html to mimic our change in workbench.html, the terminal (and code-server) fail to load:
this means using window.location.origin results in the Terminal working.
And if you look upstream, they both use that as well:
I think this is enough evidence to open a PR so that CI builds and we can test a full build via npm.
Wait actually...now I'm not sure 🤔 That change to window.location from window.location.origin only happened on our side inside workbench-dev.html which I believe is only used in Development (at least it shouldn't be used in prod unless I'm missing something) so now I'm not sure about this fix I proposed.
But it also makes me question why we'd make that change in workbench-dev and not workbench 🤔
We did change the order of the patches to make it easier apply the display patch. See here. I wonder if that could have caused this.
I may try applying all the patches but the display language and see if that work.
No luck there.
So this 983269f works locally when you run code-server in development mode aka yarn watch with Caddy.
@oxy and I paired on this. We paired on this. We made the correct change in workbench-dev.html but not workbench.html. My PR has been updated and now we need to check once again after CI finishes.
Activity
[-][Bug]: [/-][+][Bug]: terminal not working when your root_path is not /[/+][-][Bug]: terminal not working when your root_path is not /[/-][+][Bug]: terminal not working when your web base_path is not /[/+]benz0li commentedon Jul 5, 2022
I am experiencing the same issue. Julia/Python REPL and R terminal are also not working. Furthermore, the Jupyter extension fails to activate.
benz0li commentedon Jul 6, 2022
@jsjoeio The changes regarding
baseUrlwhen comparing/opt/code-server/lib/vscode/out/vs/code/browser/workbench/workbench.htmlfrom code-server v4.4.0 to v4.5.0:CodingJinxx commentedon Jul 6, 2022
Having the same issue, staying on 4.40v for the time being
aghontpi commentedon Jul 6, 2022
➕ same issue
x86_64network request path is wrong
some of the files load with correct path, (in the img, it should be "https://{hostname}/code/{other stuff}"

but some load with incorrect path

23fo commentedon Jul 7, 2022
same issue,and python extension fails to activate.
benz0li commentedon Jul 7, 2022
Cross reference: #5326
jsjoeio commentedon Jul 11, 2022
Hi all - thank you for the reports and the details! We had all last week off for the holidays so I'm just now seeing this. @code-asher is out until Thursday. I'm going to start investigating this today.
Hoping I should be able to easily reproduce with Caddy
jsjoeio commentedon Jul 11, 2022
Investigation Notes
I'll update this comment with my findings as I investigate this issue.
The Issue
Folks are having issues using the Integrated Terminal when they run code-server no on the root path i.e.
/ide. This is very common.Steps to reproduce
brew upgrade code-server- upgrade to latest release (v4.5.0)code-server- run code-servercaddy run- run Caddy and serve code-server on sub-pathScreenshot
What could have caused this?
Whenever issues like this happen, it's usually related to a VS Code upgrade which is the most brittle part of the codebase.
@benz0li left a helpful diff here to show any changes related to
baseUrl.I'm going to look at the commits for the 1.68 upgrade to see what we documented about the change.
Nothing stands out in particular there. It seems like the
baseUrlis wrong for anything in/static/node_modules/looking at @aghontpi. I see those upstream here:https://github.com/microsoft/vscode/blob/30d9c6cd9483b2cc586687151bcbcd635f373630/src/bootstrap-window.js#L136
I don't see any recent changes so i'm hesitant to believe the change is there.
Based on the diff provided earlier, I think this could be related:
The only difference is using
window.locationin the call tonew URLinstead ofwindow.location.origin.Strangely, the MDN docs say the second argument to
new URLshould bebase: stringhere.This is in an HTML file inside a
<script />tag so I am guessing that's why we don't have any TypeScript errors. I'm going to try making that change and run code-server locally withyarn watchto see if that solves it.Actually...that may not be accurate.
So this means it went from using the
origin(string we passed) to using thehrefwhich means it's a different value:"http://localhost:8082""http://localhost:8082/ide/?folder=/Users/jp/dev/oss/tabnine-vscode"which seems the right call 🤔 https://jsfiddle.net/5ca3um8x/5/
meaning I don't know if that's the issue here.
digging around i found
window.require.getConfig()which returns an object and we seebaseUrlis not relative to root.baseUrl: "http://localhost:8082/stable-30d9c6cd9483b2cc586687151bcbcd635f373630/static/out/"thinking out loud...feels like we have logic in place to make sure
WORKBENCH_WEB_BASE_URLsupports a relative root and then this line "reverts" that back to assuming code-server is at the root:const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location.origin).toString();oddly enough,
workbench.htmlandworkbench-dev.htmldo not createbaseUrlthe same.Well, when I change
workbench-dev.htmlto mimic our change inworkbench.html, the terminal (and code-server) fail to load:this means using
window.location.originresults in the Terminal working.And if you look upstream, they both use that as well:
I think this is enough evidence to open a PR so that CI builds and we can test a full build via npm.
Wait actually...now I'm not sure 🤔 That change to
window.locationfromwindow.location.originonly happened on our side insideworkbench-dev.htmlwhich I believe is only used in Development (at least it shouldn't be used in prod unless I'm missing something) so now I'm not sure about this fix I proposed.But it also makes me question why we'd make that change in
workbench-devand notworkbench🤔I'll open a PR and test a build anyway.
Unsurprisingly, that did not work.
I'm starting back on this again.
Next, I'm looking at all changed files between 4.4.0 and 4.5.0.
We did change the order of the patches to make it easier apply the display patch. See here. I wonder if that could have caused this.
I may try applying all the patches but the display language and see if that work.
No luck there.
So this 983269f works locally when you run code-server in development mode aka
yarn watchwith Caddy.@oxy and I paired on this. We paired on this. We made the correct change in
workbench-dev.htmlbut notworkbench.html. My PR has been updated and now we need to check once again after CI finishes.