Closed natecox closed 2 years ago
I don't use heroku, so I don't know how to test it. Is it respecting the preloaders? So if you have spring
running you just start it with bundle exec spring heroku local
?
The heroku cli is a standalone command, so I'd never thought to run it bia bundle exec
. Apparently it works, but it does generate some errors I don't see when I run it standalone:
➜ bundle exec heroku local
[OKAY] Loaded ENV .env File as KEY=VALUE Format
8:00:16 AM web.1 | Puma starting in single mode...
8:00:16 AM web.1 | * Version 3.12.1 (ruby 2.6.2-p47), codename: Llamas in Pajamas
8:00:16 AM web.1 | * Min threads: 5, max threads: 5
8:00:16 AM web.1 | * Environment: development
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/2.6.0/json/version.rb:4: warning: already initialized constant JSON::VERSION
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/json-2.2.0/lib/json/version.rb:4: warning: previous definition of VERSION was here
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/2.6.0/json/version.rb:5: warning: already initialized constant JSON::VERSION_ARRAY
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/json-2.2.0/lib/json/version.rb:5: warning: previous definition of VERSION_ARRAY was here
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/2.6.0/json/version.rb:6: warning: already initialized constant JSON::VERSION_MAJOR
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/json-2.2.0/lib/json/version.rb:6: warning: previous definition of VERSION_MAJOR was here
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/2.6.0/json/version.rb:7: warning: already initialized constant JSON::VERSION_MINOR
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/json-2.2.0/lib/json/version.rb:7: warning: previous definition of VERSION_MINOR was here
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/2.6.0/json/version.rb:8: warning: already initialized constant JSON::VERSION_BUILD
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/json-2.2.0/lib/json/version.rb:8: warning: previous definition of VERSION_BUILD was here
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/2.6.0/json/common.rb:100: warning: already initialized constant JSON::NaN
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/json-2.2.0/lib/json/common.rb:100: warning: previous definition of NaN was here
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/2.6.0/json/common.rb:102: warning: already initialized constant JSON::Infinity
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/json-2.2.0/lib/json/common.rb:102: warning: previous definition of Infinity was here
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/2.6.0/json/common.rb:104: warning: already initialized constant JSON::MinusInfinity
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/json-2.2.0/lib/json/common.rb:104: warning: previous definition of MinusInfinity was here
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/2.6.0/json/common.rb:129: warning: already initialized constant JSON::UnparserError
8:00:16 AM web.1 | /Users/nate/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/json-2.2.0/lib/json/common.rb:129: warning: previous definition of UnparserError was here
Running as a spring command doesn't seem to work, but I'll admit that I'm pretty new to the rails ecosystem and I don't fully understand how spring works, so maybe it's trivial to get it to work?
➜ bundle exec spring heroku local
Version: 2.0.2
Usage: spring COMMAND [ARGS]
Commands for spring itself:
binstub Generate spring based binstubs. Use --all to generate a binstub for all known commands. Use --remove to revert.
help Print available commands.
server Explicitly start a Spring server in the foreground
status Show current status.
stop Stop all spring processes for this project.
Commands for your application:
rails Run a rails command. The following sub commands will use spring: console, runner, generate, destroy, test.
rake Runs the rake command
@natecox you could evaluate this function and try it out.
(defun projectile-rails-server ()
"Runs rails server command"
(interactive)
(when (not (projectile-rails--file-exists-p "config/environment.rb"))
(user-error "You're not running it from a rails application."))
(if (member projectile-rails-server-buffer-name (mapcar 'buffer-name (buffer-list)))
(switch-to-buffer projectile-rails-server-buffer-name)
(projectile-rails-with-root
(compile "heroku local" 'projectile-rails-server-mode))))
I personally don't start the server in emacs because it slows down the server a lot. I takes a lot longer to print out all of the output from a single request. I always wanted to sit down one day and try and make it faster, but the end of the day emacs will always be slower than a terminal emulator.
@asok That seems to work fine. I hear you on the speed issue, but I really like having everything easily accessible from the same place, so it's a tradeoff I'm willing to make.
@natecox I've pushed a change you could test by setting projectile-rails-custom-server-command
to "heroku local".
Confirmed that projectile-rails-custom-server-command
works. I think this is a fair solution overall, and I can probably figure out how to set it at the directory level (.dir-locals.el maybe?).
It may be worthwhile to consider expanding on this at some point; checking for a Procfile
at the root of the project and offering custom variables for if to use a procfile command when present, and another for which
to use would be super cool.
It may be worthwhile to consider expanding on this at some point; checking for a Procfile at the root of the project and offering custom variables for if to use a procfile command when present, and another for which to use would be super cool.
As I mentioned before I don't use it, so it's hard for me to support it. But if anyone would make a PR I could merge it in.
I'm loving this integration, so thank you for all the work so far!
That said, I would really prefer to use
heroku local
as my server command, so that I can get it to start guard, etc, from my Procfile, and use my env vars via convention. I don't see an obvious way to accomplish this within the package and have just been running a separate terminal to handle it.Is there any support for this that I've missed? Can you add it, if not?