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

puma-dev #184

Closed
joelmoss opened this issue Nov 3, 2023 · 6 comments
Closed

puma-dev #184

joelmoss opened this issue Nov 3, 2023 · 6 comments

Comments

@joelmoss
Copy link

joelmoss commented Nov 3, 2023

I use puma-dev to run my rails apps, but ruby-lsp-rails doesn't know that...

Rails server is not running. To get Rails features in the editor, boot the Rails server

Any way to get it working with puma-dev? thx

@vinistock
Copy link
Member

Thank you for the report! To determine if the Rails app is running, we just make a request to the Rack app we automatically mount.

I don't know how puma-dev works, but maybe it's changing the booting behaviour somehow? If you boot the Rails app, do you get a tmp/app_uri.txt file? And does it contain the right uri for your app?

@joelmoss
Copy link
Author

joelmoss commented Nov 6, 2023

I couldn't tell you exactly how it works, but I think the idea is that there is a global service that runs and manages the registered puma apps. The idea is that there is no explicit start/stop with rails server of the server needed.

There is no tmp/app_uri.txt, but there is tmp/puma-dev-*.sock.

@vinistock
Copy link
Member

Okay, the absence of that file is certainly the issue. Now, we need to understand why the file isn't there. We use a railtie initializer to write the URL of your app to that file - otherwise, the Ruby LSP addon has no way of knowing which URL to make requests to.

What I suspect might be happening based on your description, is that puma-dev might hook into internals and skip the server options, which is what we use to figure out the host and port.

If you add a breakpoint/puts statement in the initializer, we can probably figure out if that's the case.

If that is indeed what's happening, then we need to understand if there is a way of determining the host and port when using puma-dev. Again, there's no way to make requests to the Rails app from the Ruby LSP side of things if we don't know the full URL, so we need to be able to generate that file automatically - especially considering that you can change ports and stuff through command line arguments.

@technicalpickles
Copy link

@joelmoss maybe double check you don't have require: false for ruby-lsp-rails?

I was seeing a similar problem with regular puma, found this thread, and seeing this:

We use a railtie initializer to write the URL of your app to that file

Made me realize I copied the line for ruby-lsp-rspec, which does use require: false.

@vinistock
Copy link
Member

You should not add require: false for ruby-lsp-rails or else the Rack App will never boot and database introspection won't work.

@andyw8
Copy link
Contributor

andyw8 commented Feb 15, 2024

We're changing how the LSP communicates with Rails, so this will no longer be a problem:

#256

(not yet released but should be soon).

@andyw8 andyw8 closed this as completed Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants