question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

user-data-dir config does not expand ~ alias as user home

See original GitHub issue

OS/Web Information

  • Web Browser: Chrome
  • Local OS: ChromeOS
  • Remote OS: Manjaro
  • Remote Architecture: Linux
  • code-server --version: 3.10.2 387b12ef4ca404ffd39d84834e1f0776e9e3c005

Steps to Reproduce

I’m trying to follow https://github.com/cdr/code-server/blob/main/docs/FAQ.md#how-can-i-reuse-my-vs-code-configuration. The instructions indicate that ~ can be used within the value. I am trying to point at my local ~/.config/Code for shared settings.

Create in ~/.config/code-server/config.yaml:

bind-addr: 0.0.0.0:8443
auth: password
password: REDACTED
cert: false
user-data-dir: ~/.config/Code

I am then running code-server via systemctl start code-server@myusername.service

Expected

Code-server should run with shared settings of my ~/.config/Code directory

Actual

When opening in client, a blank screen is shown.

If the user-data-dir in config.yml is instead replaced with the absolute path: /home/myusername/.config/Code it loads properly.

I cannot alternatively get this to work with $HOME.

This would be useful for code-server configs to be cross compatible between MacOS and Linux (where /home and /Users is often th differentiation).

Logs

Note the ‘Using user-data-dir’ line where it does not appear to expand ~ as expected:

Jun 28 09:06:28 d4bequiet code-server[31942]: [2021-06-28T13:06:28.307Z] info  code-server 3.10.2 387b12ef4ca404ffd39d84834e1f0776e9e3c005
Jun 28 09:06:28 d4bequiet code-server[31942]: [2021-06-28T13:06:28.308Z] info  Using user-data-dir /~/.config/Code
Jun 28 09:06:28 d4bequiet code-server[31942]: [2021-06-28T13:06:28.316Z] info  Using config file ~/.config/code-server/config.yaml
Jun 28 09:06:28 d4bequiet code-server[31942]: [2021-06-28T13:06:28.316Z] info  HTTP server listening on http://0.0.0.0:8443
Jun 28 09:06:28 d4bequiet code-server[31942]: [2021-06-28T13:06:28.316Z] info    - Authentication is enabled
Jun 28 09:06:28 d4bequiet code-server[31942]: [2021-06-28T13:06:28.316Z] info      - Using password from ~/.config/code-server/config.yaml
Jun 28 09:06:28 d4bequiet code-server[31942]: [2021-06-28T13:06:28.316Z] info    - Not serving HTTPS
Jun 28 09:06:31 d4bequiet code-server[31942]: [2021-06-28T13:06:31.978Z] error vscode is not running Error: vscode is not running
Jun 28 09:06:31 d4bequiet code-server[31942]:     at VscodeProvider.send (/usr/lib/code-server/out/node/vscode.js:206:19)
Jun 28 09:06:31 d4bequiet code-server[31942]:     at VscodeProvider.<anonymous> (/usr/lib/code-server/out/node/vscode.js:198:30)
Jun 28 09:06:31 d4bequiet code-server[31942]:     at step (/usr/lib/code-server/out/node/vscode.js:63:23)
Jun 28 09:06:31 d4bequiet code-server[31942]:     at Object.next (/usr/lib/code-server/out/node/vscode.js:44:53)
Jun 28 09:06:31 d4bequiet code-server[31942]:     at fulfilled (/usr/lib/code-server/out/node/vscode.js:35:58)
Jun 28 09:06:31 d4bequiet code-server[31942]:     at processTicksAndRejections (internal/process/task_queues.js:97:5)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bdeforecommented, Dec 26, 2021

keepalive

1reaction
code-ashercommented, Jun 29, 2021

The shell expands tilde and environment variables but there’s nothing in the Node code that does the same.

Maybe we can call out to the shell so it can handle the expansions since there will be many edge cases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bash aliases do not expand even with shopt expand_aliases
It doesn't seem work if you set the alias on the same line as it's used. Probably something to do with how aliases...
Read more >
Creating and Using Profiles - The Chromium Projects
Create a shortcut or alias that launches the browser, using the --user-data-dir command-line argument to specify the profile's location.
Read more >
What could be preventing my alias from expanding in a shell ...
Aliases are expanded when a command is read, not when it is executed. ... on a separate line, and do not use alias...
Read more >
bashrc 6-8-2019 - gists · GitHub
ageis's ~/.bashrc 🖥️ with numerous useful functions, aliases and one-liners. ... google-chrome --no-sandbox --user-data-dir=/root/.config/google-chrome".
Read more >
how to expand aliases inline in bash? - Super User
You can press Ctrl - Alt - e to perform the readline function shell-expand-line which will do alias, history and word expansions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found