Hi!
I'm trying to initialize my lsp-mode (at Emacs) using the ts-ls tsserver to do so. But, when I start the server the following error happens:
Command "/home/odelucca/.asdf/shims/typescript-language-server --tsserver-path /home/odelucca/.asdf/shims/tsserver --stdio" is present on the path.
Command "/home/odelucca/.asdf/shims/typescript-language-server --tsserver-path /home/odelucca/.asdf/shims/tsserver --stdio" is present on the path.
Found the following clients for /home/odelucca/Code/odelucca/execution-mode@budproj/src/server/index.ts: (server-id ts-ls, priority -2)
The following clients were selected based on priority: (server-id ts-ls, priority -2)
[tsserver] asdf: No preset version installed for command tsserver
Please install the missing version by running one of the following:
asdf install nodejs 15.0.0
or add one of the following in your .tool-versions file:
[tsserver] nodejs 12.18.1
Cancelling textDocument/codeAction(5) in hook post-command-hook
It is strange, because I have NodeJS version 12.18.1 installed, as you can se:
execution-mode@budproj on feature/initial-setup [?] via ⬢ v15.0.0 took 3s
❯ asdf list nodejs
10.15.0
10.17.0
12.16.0
12.16.1
12.18.1
12.18.2
12.18.3
13.10.1
13.9.0
14.0.0
14.2.0
15.0.0
And also, the project is not using NodeJS 12.18.1, it is using 15.0.0:
# .tool-versions
nodejs 15.0.0
If I change the .tool-versions file to use Node 12.18.1 it works, but I should not do so, since my project required 15.0.0
Any idea how to fix it?
I have the same problem too!!! With asdf current I have nodejs 14.15.0 ... I intsalled it globally and also I use it locally for my project (.tool-versions has nodejs 14.15.0). But if I do node -v from my terminal it shows me v.12.15.0
My OS Ubuntu 20.04.1 LTS
I've upgraded node plugin of asdf, but it didn't resolve the problem
I've solved the problem by adding
. $HOME/.asdf/asdf.sh
to my .zshrc file. I didn't do it earlier because in docs they say
OR use a ZSH Framework plugin like asdf for oh-my-zsh which will source this script and setup completions.
And I use this plugin, because I use oh-my-zsh. So, I think that the bug is inside oh-my-zsh plugin. @delucca , just add what I mentioned and reopen your terminal. This BTW works in Linux
@delucca can you show us your asdf info?
@maxie7 My .zshrc looks like this:
fpath=($HOME/.asdf/completions $fpath)
plugins=(
asdf
)
And I cannot reproduce this issue, so I do not think it's the OMYZSH plugin.
my .zshrc:
...
plugins=(
asdf
bundler
bower
catimg
colored-man-pages
command-not-found
composer
docker
dotenv
fasd
git
git-flow
github
gem
gpg-agent
httpie
heroku
jira
rvm
rake
ruby
rails
repo
# ssh-agent
sublime
symfony2
systemd
sudo
sprunge
urltools
ubuntu
npm
web-search
zsh-autosuggestions
)
...
. $HOME/.asdf/asdf.sh
. $HOME/.asdf/completions/asdf.bash
without
. $HOME/.asdf/asdf.sh
at the end of my .zshrc it doesn't work
I've tested it in two laptops: 1) Debian GNU/Linux 10 (buster) and 2) Ubuntu 20.04.1 LTS
I don't know if this is related, but I was having a similar problem with trying to run yarn:
% yarn -v
asdf: No preset version installed for command yarn
Please install the missing version by running one of the following:
asdf install nodejs 13.8.0
or add one of the following in your .tool-versions file:
nodejs 12.13.0
I eventually (after longer than I'm willing to admit 😄) realized that because I had just installed nodejs 13.8.0, yarn wasn't installed. Instead of erroring out with "command not found", the shim returns a well-intentioned-but-not-quite-helpful message.
I believe @CraigCottingham has found the cause of the issue, I will use the details he provided for a scenario. I may be off with some of this, but it's the gist as I understand it today.
asdf plugins add shims to the ~/.asdf/shims dir for each binary that the plugin you install manages. That is, asdf plugin add nodejs will add shims for npm, npx, node and perhaps some others. When you install a global binary such as vercel or yarn via a particular node version, it will create the shim for that binary in ~/.asdf/shims. This shim is not associated with a version, but is just an indicator that asdf is managing that binary. When the binary is executed, asdf will lookup the shim, find it's associated plugin, search for a .tool-versions file (or legacy version file if specified) to determine which version of node the user wants, attempts to find the the specific binary under the provided version of node (in say that versions global node_modules). If the binary does not exist, it cannot be executed and thus asdf says
asdf: No preset version installed for command yarn
Please install the missing version by running one of the following:
asdf install nodejs 13.8.0
or add one of the following in your .tool-versions file:
nodejs 12.13.0
This error is somewhat unhelpful. It should probably read something like:
asdf: No installed command <yarn> found for version <nodejs 13.8.0>
Command <yarn> was found for version <nodejs 12.13.0>
Either install <yarn> for version <nodejs 13.8.0>
or
revert to version <nodejs 12.13.0> with `asdf local nodejs 13.8.0`
To resolve this issue, I think we need to update the error messaging for this scenario.
@delucca does this description help you resolve your issue?
@jthegedus I think it does.
I'm no longer facing this issue since I've moved from Emacs to Atom, but I think that the error message would make it easier to understand.
But, there is a more complex issue here. I was using a plugin called asdf-yarn, and I think most Yarn users do too. Why does asdf is searching for yarn inside asdf-node instead of asdf-yarn?
@delucca Sorry, I used the details from @CraigCottingham in this thread. tsserver seemed to be the binary you were facing issues with, his example was yarn installed as a global via npm i -g yarn with the nodejs plugin.
But, there is a more complex issue here. I was using a plugin called asdf-yarn, and I think most Yarn users do too. Why does asdf is searching for yarn inside asdf-node instead of asdf-yarn?
Had yarn been installed via the asdf-yarn plugin then asdf would have errored with
asdf: No preset version installed for command yarn
Please install the missing version by running one of the following:
asdf install yarn 1.22.10
or add one of the following in your .tool-versions file:
yarn 1.20.0
Simplifying my earlier explanation:
asdf > plugins > install tools > shim stored in a global lookup (version independent) @ ~/.asdf/shims.
when a command is executed:
~/.asdf/shimsyarn it could be either asdf-yarn or asdf-nodejs plugin, but asdf knows).tool-versionsThere is a situation whereby a shim is created for the same tool from different plugins (see https://github.com/asdf-vm/asdf/issues/828). Let's take yarn for instance. It can be installed via:
asdf-yarn with asdf install yarn <version>asdf-nodejs with npm i -g yarnon my machine with both asdf-nodejs and asdf-yarn with an installed version of yarn:
# List the plugins and versions that provide a command
➜ asdf shim-versions yarn
nodejs 14.15.2
yarn 1.22.10
# with no version for either nodejs or yarn plugins in .tool-versions
# or versions are set, but those versions didn't have the binary installed for them
➜ asdf which yarn
No preset version installed for command yarn
Please install a version by running one of the following:
asdf install nodejs 14.8.0
or add one of the following versions in your config file at /home/jthegedus/.tool-versions
nodejs 14.15.2
yarn 1.22.10
# with nodejs version set in .tool-versions
➜ asdf which yarn
/home/jthegedus/.asdf/installs/nodejs/14.15.2/.npm/bin/yarn
# with yarn version set in .tool-versions
➜ asdf which yarn
/home/jthegedus/.asdf/installs/yarn/1.22.10/bin/yarn
# with both nodejs & yarn versions set in .tool-versions
➜ asdf which yarn
/home/jthegedus/.asdf/installs/nodejs/14.15.2/.npm/bin/yarn
# this is where my knowledge is lacking as I am unfamiliar with why nodejs is preferred over yarn here as swapping the position in the .tool-versions file doesn't affect resolution, so I think it is dependent on the order returned from `asdf shim-versions yarn`
It is up to the user to manage whether a shim is managed by two different plugins. We provide the tools to investigate this with asdf which <tool> and asdf shim-versions so they know which installation is executed.
We need to improve our error outputs however to make the situation that started this thread more clear.