ruby-lsp-rails icon indicating copy to clipboard operation
ruby-lsp-rails copied to clipboard

Add ability to configure the BASE_COMMAND

Open pusewicz opened this issue 1 year ago • 2 comments

Currently, the BASE_COMMAND is hardcoded to bin/rails test.

It would be wonderful to be able to configure this command to something else.

Use case

Using tilt, docker-compose or similar solution requires prefixing most of the commands in order to execute them in the container.

Having the ability to configure this command would allow for easier integration with the tools mentioned above.

One could have a custom bin/docker-rails script available that would do the path transformation and run the bin/rails test command in the correct container.

pusewicz avatar Mar 18 '24 18:03 pusewicz

It would be best to develop in an environment where rails is able to run. The best option I know for this would be DevContainers, however personally I'm not a huge fan of them, stuff just tends to break on me, so I find myself outside most of the time anyways.

You could add the following to your .bashrc or similar:

bin/rails () {
  if [ "$PWD" == "/path/to/your/project" ] && [ "$1" == "test" ]; then
    shift;
    # I have a service called tests which just calls bin/rails test
    docker compose run --rm tests "$@"
  else
    ./bin/rails "$@"
  fi;
}

The runner which currently provides schema hints will also requires rails to be able to run, so that will just not work. Overall I find this pretty hacky and not very portable but hey, at least tests will do their thing.

Earlopain avatar Apr 10 '24 09:04 Earlopain

We have a very similar workflow, running rails on docker; so it'd be really great if we can customize the command. At the moment, all testing features are unusable for us.

okan-instrumentl avatar May 20 '24 09:05 okan-instrumentl