Comments (15)
Elvish is not responsible for interpreting the shebang line, so there's something else going on.
How did you set Elvish to be your default shell?
from elvish.
Also - what's the name of your script and can you elaborate why it's necessary for your setup?
I took a look at the vscode-neovim extension and it doesn't mention that you need to create a custom script to use it, so I suppose it's some custom setup you're using?
from elvish.
Elvish is not responsible for interpreting the shebang line, so there's something else going on.
How did you set Elvish to be your default shell?
I set default shell by issue this command: sudo chsh -s $(which elvish) $USER
note that i use macos sonoma and nix to install elvish.
which elvish
resolve to smth like /Users/user/.nix-profile/bin/elvish
but this should not be any problem, just to verbose
more.
I did re-login/out before doing any test.
Also - what's the name of your script and can you elaborate why it's necessary for your setup?
it's named vscode-neovim.sh
as in the image.
I took a look at the vscode-neovim extension and it doesn't mention that you need to create a custom script to use it, so I suppose it's some custom setup you're using?
you can check it here: https://github.com/milanglacier/nvim#seamless-integration-with-vscode
this script due to users want to use a separate neovim config for vscode-neovim instance and the default neovim that load ~/.config/nvim
so i have another folder ~/.config/vscode-neovim
that store neovim config for neovim instance of vscode-neovim.
from elvish.
OK thanks, I understand what you are trying to do now.
There seems to be quite a few moving parts in this setup you are using, and any component could be passing code through the login shell (rather than the correct thing, using an API that maps to a direct exec call without going through the shell), so making sure that the vscode-neovim
script is using bash may not be sufficient, as is apparently the case here...
from elvish.
Some things to check:
- Does your setup work correctly if you change your login shell back to bash or zsh?
- Did you try the alternative approach of separating the config directory (setting
vscode-neovim.NVIM_APPNAME
)?
from elvish.
Hmm looking at the error code you're getting (ENOENT) - did you set vscode-neovim.neovimExecutablePaths.darwin
to the full absolute path of your script?
from elvish.
before switched to elvish, i use zsh and the above script just work out-of-box
Note that Zsh and Bash are both POSIX compatible shells (more or less). I would expect that you would experience similar problems if you used another non-POSIX shell such as Fish or Xonsh. This type of situation is why the best practice is to leave your "login" shell something like Zsh or Bash and configure your terminal emulator to spawn Elvish instead of your login shell; see https://elv.sh/get/default-shell.html. As @hanche suggested in the IM chat it a useful experiment is to try invoking the relevant programs with something like export SHELL=/bin/bash
to ensure the default shell for Vscode or the Nvim plugin is POSIX compatible.
My primary OS is also macOS and it is very frustrating that it doesn't support a usable strace
or truss
command. It's dtruss
and dtrace
tools are useful but not for situations like this. What I typically do is create a "wrapper" script that looks something like this to capture the arguments to a program:
#!/bin/sh
echo "$@" > /tmp/$$.args
exec /path/to/real-program "$@"
Where the original program is renamed to /path/to/real-program and the script is installed as the original /path/to/program whose invocation we want to track.
from elvish.
Some things to check:
- Does your setup work correctly if you change your login shell back to bash or zsh?
- Did you try the alternative approach of separating the config directory (setting
vscode-neovim.NVIM_APPNAME
)?
yes, default shell is zsh
which work out-of-box
I don't have another approach to this.
vscode-neovim.neovimExecutablePaths.darwin
this set to vscode-neovim.sh
and it's avail when typing in terminal --> vscode-neovim.sh
is avail in PATH
for use. (with elvish as default shell)
from elvish.
before switched to elvish, i use zsh and the above script just work out-of-box
Note that Zsh and Bash are both POSIX compatible shells (more or less). I would expect that you would experience similar problems if you used another non-POSIX shell such as Fish or Xonsh. This type of situation is why the best practice is to leave your "login" shell something like Zsh or Bash and configure your terminal emulator to spawn Elvish instead of your login shell; see https://elv.sh/get/default-shell.html. As @hanche suggested in the IM chat it a useful experiment is to try invoking the relevant programs with something like
export SHELL=/bin/bash
to ensure the default shell for Vscode or the Nvim plugin is POSIX compatible.My primary OS is also macOS and it is very frustrating that it doesn't support a usable
strace
ortruss
command. It'sdtruss
anddtrace
tools are useful but not for situations like this. What I typically do is create a "wrapper" script that looks something like this to capture the arguments to a program:#!/bin/sh echo "$@" > /tmp/$$.args exec /path/to/real-program "$@"
Where the original program is renamed to /path/to/real-program and the script is installed as the original /path/to/program whose invocation we want to track.
this can be more useful than force macos user default shell but when i try to set vscode's terminal default shell, i can't:
"terminal.integrated.shell.osx":
is hidden and not seem to work. is there a way to change vscode's default shell?
from elvish.
ok i got that, it's smth like "terminal.integrated.defaultProfile.osx": "elvish",
from elvish.
@tmpm697 Glad to know you worked around the issue. I've updated https://elv.sh/get/default-shell.html to include instruction for using Elvish from VS Code's terminal and documented vscode-neovim's incompatibility issue.
from elvish.
@tmpm697 Glad to know you worked around the issue. I've updated https://elv.sh/get/default-shell.html to include instruction for using Elvish from VS Code's terminal and documented vscode-neovim's incompatibility issue.
thanks, if having elvish shell this way, is that it will first spawn zsh
and then do exec elvish
?
if true, then elvish will get all exported env vars from zsh?
from elvish.
thanks, if having elvish shell this way, is that it will first spawn zsh and then do exec elvish?
if true, then elvish will get all exported env vars from zsh?
Yes, because that is how env vars work; at least on Unix like operating systems such as macOS and Linux. Env vars are private to each process. When a process, such as zsh
, spawns a new process it normally tells the OS to pass a copy of its env vars to the new process.
from elvish.
@tmpm697 Glad to know you worked around the issue. I've updated https://elv.sh/get/default-shell.html to include instruction for using Elvish from VS Code's terminal and documented vscode-neovim's incompatibility issue.
thanks, if having elvish shell this way, is that it will first spawn
zsh
and then doexec elvish
?if true, then elvish will get all exported env vars from zsh?
I don't think any terminal has the literal behavior you're describing. Normally the login shell won't be involved. tmux
is an exception - if you configured tmux
to launch Elvish, you'll still get your login shell in the terminal, which will pass its environment variables to tmux and then to Elvish.
AFAICT some Linux desktop environments involve the login shell at some point during the login process, so you can end up getting environment variables from the profile file of the login shell, but you're using macOS so that's not relevant to you.
thanks, if having elvish shell this way, is that it will first spawn zsh and then do exec elvish?
if true, then elvish will get all exported env vars from zsh?Yes, because that is how env vars work; at least on Unix like operating systems such as macOS and Linux. Env vars are private to each process. When a process, such as
zsh
, spawns a new process it normally tells the OS to pass a copy of its env vars to the new process.
I think you're answering @tmpm697's second question assuming that the answer to the first question is yes, which I believe is not the case.
from elvish.
vscode's settngs:
"terminal.integrated.defaultProfile.osx": "elvish",
no idea but this is number of vars in elvish and zsh:
new vscode terminal --> starting shell is elvish:
~/s/nix ➜ e:env | wc -l
47
~/s/nix ➜ zsh
~/s/nix ➜ env | wc -l
47
compare zsh's env | rg test_var
vs elvish's e:env | rg test_var
look the same.
so it seems that vscode on macos spawn zsh first and then exec elvish
that automatically import all exported vars from zsh?
I don't set-env
in my elvish config, but surprisingly if u set same var in evlish via set-env
, it'll overwrite exported var from zsh but seem expected.
from elvish.
Related Issues (20)
- Unique symbols HOT 1
- Disable flow control by default HOT 1
- Race condition when starting multiple instances simultaneously HOT 2
- RSS support for the blog
- Support semantic prompts (OSC 133) HOT 1
- Directory Elvish is launched from doesn't seem to be added to location history HOT 10
- Docs for embedding Elvish? HOT 6
- RISC-V binaries HOT 5
- "Command not found" error when running a batch script with space in path with an argument with space HOT 16
- API to change the in-command colours? HOT 3
- Cursor and prompt control in function to avoid prompt flick HOT 10
- document and change behavior of `doc:find` with no arguments
- Indexing into a list of maps HOT 2
- listbox_window: integer divide by zero HOT 6
- Add `&key` option to `compact`.
- Are there any good examples for custom completion script? HOT 2
- Add helpful message for arity mismatch on function call
- Minibuffer namespace
- COMPLETING argument menu shown even when only one completion on paths that start ~/ HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elvish.