Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looks like --puppet-settings=--modulepath doesn't work #235

Open
Felixoid opened this issue Apr 3, 2020 · 2 comments
Open

Looks like --puppet-settings=--modulepath doesn't work #235

Felixoid opened this issue Apr 3, 2020 · 2 comments
Assignees

Comments

@Felixoid
Copy link

Felixoid commented Apr 3, 2020

Describe the Bug

Hello. I launch both puppet-languageserver and puppet-languageserver-sidecar with --puppet-settings=--modulepath,/path/to/modules/ and it doesn't work. Basically, it gives nothing.

Expected Behavior

I expect to get the data for all included modules.

Steps to Reproduce

Steps to reproduce the behavior:
Here the Dockerfile to build a testing environment

FROM archlinux/base

RUN pacman -Sy base-devel --noconfirm git && \
  echo 'nobody ALL = NOPASSWD: /usr/bin/pacman' | tee /etc/sudoers.d/nobody-pacman && \
  yes | pacman -Scc

USER nobody

RUN  git clone https://aur.archlinux.org/puppet-editor-services.git /tmp/puppet-editor-services && \
  cd /tmp/puppet-editor-services && \
  HOME=/tmp/puppet-editor-services makepkg -is --noconfirm && \
  cd / && \
  rm -rf /tmp/* && \
  yes | sudo pacman -Scc

WORKDIR /tmp

ENTRYPOINT /bin/bash

To launch container and reproduce the issue run the next commands:

docker run -it --rm puppet-editors
for repo in https://github.com/puppetlabs/puppetlabs-stdlib.git https://github.com/puppetlabs/puppetlabs-apt.git https://github.com/innogames/puppet-clickhouse.git; do git clone $repo; done
HOME=/tmp ruby /opt/puppet-editor-services/puppet-languageserver-sidecar --action workspace_types --puppet-settings=--modulepath,/tmp --debug STDOUT
HOME=/tmp ruby /opt/puppet-editor-services/puppet-languageserver-sidecar --action workspace_types --puppet-settings=--moduledir,/tmp --debug STDOUT

The output of previous commands is:

[nobody@5808fd9be905 tmp]$ HOME=/tmp ruby /opt/puppet-editor-services/puppet-languageserver-sidecar --action workspace_types --puppet-settings=--moduledir,/tmp --debug STDOUT; echo
I, [2020-04-03T22:28:45.932174 #103]  INFO -- : Language Server Sidecar is v0.25.0
D, [2020-04-03T22:28:45.932205 #103] DEBUG -- : Loading gems...
I, [2020-04-03T22:28:46.597534 #103]  INFO -- : Using Puppet v6.14.0
D, [2020-04-03T22:28:46.597573 #103] DEBUG -- : Detected additional puppet settings ["--moduledir", "/tmp"]
D, [2020-04-03T22:28:46.603557 #103] DEBUG -- : Executing workspace_types action
null
[nobody@5808fd9be905 tmp]$ HOME=/tmp ruby /opt/puppet-editor-services/puppet-languageserver-sidecar --action workspace_types --puppet-settings=--modulepath,/tmp --debug STDOUT; echo
I, [2020-04-03T22:28:54.030934 #105]  INFO -- : Language Server Sidecar is v0.25.0
D, [2020-04-03T22:28:54.030978 #105] DEBUG -- : Loading gems...
I, [2020-04-03T22:28:54.754431 #105]  INFO -- : Using Puppet v6.14.0
D, [2020-04-03T22:28:54.754474 #105] DEBUG -- : Detected additional puppet settings ["--modulepath", "/tmp"]
D, [2020-04-03T22:28:54.761187 #105] DEBUG -- : Executing workspace_types action
null

Environment

  • Version 0.25.0
  • Platform Arch linux
@Felixoid Felixoid added the bug Something isn't working label Apr 3, 2020
@jpogran jpogran removed the bug Something isn't working label Apr 7, 2020
@jpogran
Copy link
Contributor

jpogran commented Apr 7, 2020

Hi @Felixoid, thank you for the detailed report!

Can I ask what you are trying to accomplish? Using puppet-language-sidecar directly isn't something we intended as a public API. It's intended to used by the puppet-languageserver, so there is a fair bit of setup and specific parameters to use in different situations. None of this is generally documented because it's internal, but Glenn has wrote some amazing spec tests that exercise the entire suite of functionality you could use to get an idea of what is needed by what. If that doesn't help for examples, you'll have to look at the source to see which action is used to get which type of data.

Making an assumption, I think you are trying to list all types in the current workspace. I'm not really familiar with pacman or makepkg, but I don't see which version of ruby you are using or any bundle install or bundle exec statements that indicate you've installed the gems needed to run this in a development setup. Assuming that you have, you have to match the action with the thing you want to get, along with which other parameters to use. You need to specify the --local-workspace, not modulepath to get that. If you look at https://github.com/puppetlabs/puppet-editor-services/blob/master/lib/puppet-languageserver/puppet_helper.rb#L294-L297, you'll see we pass the workspace_types action with the current working directory as the local_workspace. If we do that, we get something like this (with the actual json omitted for space):

root@874b47154142:/workspaces/puppet-editor-services# bundle exec puppet-languageserver-sidecar --action=workspace_types --debug=./output.log --local-workspace=./spec/languageserver-sidecar/fixtures/valid_module_workspace  
I, [2020-04-07T00:50:48.813729 #3206]  INFO -- : Language Server Sidecar is v0.25.0
D, [2020-04-07T00:50:48.827882 #3206] DEBUG -- : Loading gems...
I, [2020-04-07T00:50:51.930396 #3206]  INFO -- : Using Puppet v6.14.0
D, [2020-04-07T00:50:51.944777 #3206] DEBUG -- : Detected additional puppet settings []
D, [2020-04-07T00:50:51.985057 #3206] DEBUG -- : Detected Module Metadata in the workspace
D, [2020-04-07T00:50:51.992304 #3206] DEBUG -- : Executing workspace_types action
D, [2020-04-07T00:50:52.021076 #3206] DEBUG -- : Injected the workspace into the module loader
D, [2020-04-07T00:50:52.027561 #3206] DEBUG -- : [PuppetHelper::retrieve_types] Starting
W, [2020-04-07T00:51:03.756726 #3206]  WARN -- : [PuppetHelper::load_type_file] type /usr/local/bundle/gems/puppet-6.14.0/lib/puppet/type/component.rb did not load any types
W, [2020-04-07T00:51:21.336205 #3206]  WARN -- : [PuppetHelper::load_type_file] type /usr/local/bundle/gems/puppet-6.14.0/lib/puppet/type/whit.rb did not load any types
D, [2020-04-07T00:51:21.347568 #3206] DEBUG -- : [PuppetHelper::retrieve_types] Finished loading 13 type/s

If this doesn't help, can you reply with what you are trying to do, and maybe we can help. I'm removing the bug label for now, as we haven't identified this as actually something that isn't working yet.

@Felixoid Felixoid changed the title Looks like --puppetsettings=--modulepath doesn't work Looks like --puppet-settings=--modulepath doesn't work Apr 7, 2020
@Felixoid
Copy link
Author

Felixoid commented Apr 7, 2020

Hey @jpogran.

I've shown the example of puppet-language-sidecar as a proof, that /usr/bin/puppet-languageserver --stdio --puppet-settings=--modulepath,/path/to/puppet/modules/dir doesn't work as I expect.

Maybe, and most probably, my expectations are wrong. What am I trying to achieve is to have autocompletion when I'm working in a puppet-clickhouse project for the used modules stdlib AND apt. So my expectations according to the documentation https://puppet-vscode.github.io/docs/extension-settings/#puppet-editorservice-puppet-modulepath, that I should have the data from puppet-language-sidecar.

If --puppet-settings=--modulepath doesn't produce the data from language-server, I have two questions:

  • What this actually do?
  • How could I produce autocompletion for all my modules? E.g., for stdlib and apt, when I'm working in clickhouse?

Thank you for the comment, hopefully, there's a way to get what I need.

@glennsarti glennsarti self-assigned this Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants