lcreid / rails-5-jade

Rails 5 with Jekyll and Node on Ubuntu 18.04
MIT License
29 stars 3 forks source link

Puma won't start I think..? #32

Closed Pacn91 closed 5 years ago

Pacn91 commented 5 years ago

Hi, I'm getting a problem with a new project that I created using your box. I follow your instructions but when I start my rails server and I go to my browser at: localhost:3000 there is no "Welcome Aboard" page. It seems that the Puma won't start, I think.

I'll tell you what I did step by step and I hope you can help me:

I tried also to start the server like you have, but it gives me an error:

vagrant@rails-5-2:/vagrant$ rails server --bind 0.0.0.0
Traceback (most recent call last):
        28: from bin/rails:3:in `<main>'
        27: from bin/rails:3:in `load'
        26: from /vagrant/bin/spring:15:in `<top (required)>'
        25: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:70:in `require'
        24: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:70:in `require'
        23: from /var/lib/gems/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
        22: from /var/lib/gems/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
        21: from /var/lib/gems/2.5.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
        20: from /var/lib/gems/2.5.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
        19: from /var/lib/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
        18: from /var/lib/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
        17: from /var/lib/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
        16: from /vagrant/bin/rails:9:in `<top (required)>'
        15: from /var/lib/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
        14: from /var/lib/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
        13: from /var/lib/gems/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
        12: from /var/lib/gems/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        11: from /var/lib/gems/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
        10: from /var/lib/gems/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
         9: from /var/lib/gems/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
         8: from /var/lib/gems/2.5.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
         7: from /var/lib/gems/2.5.0/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<top (required)>'
         6: from /var/lib/gems/2.5.0/gems/railties-5.2.3/lib/rails/command.rb:46:in `invoke'
         5: from /var/lib/gems/2.5.0/gems/railties-5.2.3/lib/rails/command/base.rb:65:in `perform'
         4: from /var/lib/gems/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
         3: from /var/lib/gems/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
         2: from /var/lib/gems/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:20:in `run'
         1: from /var/lib/gems/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:34:in `rescue in run'
/var/lib/gems/2.5.0/gems/thor-0.20.3/lib/thor/base.rb:506:in `handle_argument_error': ERROR: "rails server" was called with arguments ["0.0.0.0"] (Thor::Invoc
ationError)
Usage: "rails server [puma, thin etc] [options]"

I hope you can help me. Thank you in advance.

lcreid commented 5 years ago

Thanks for the feedback. I'm sorry you're having this issue. I confess I haven't started a new project with the most recent version of this box. I will look into it and get back to you shortly.

lcreid commented 5 years ago

I believe that what you're typing should work, but I can reproduce your problem. I can also start the Rails server by typing the following, instead of what you're typing:

rails server -b 0.0.0.0

I will try to figure out what's going on later, but hopefully this allows you to start working with the box. I will update the documentation.

Thanks again for taking the time to report the problem.

Pacn91 commented 5 years ago

I believe that what you're typing should work, but I can reproduce your problem. I can also start the Rails server by typing the following, instead of what you're typing:

rails server -b 0.0.0.0

I will try to figure out what's going on later, but hopefully this allows you to start working with the box. I will update the documentation.

Thanks again for taking the time to report the problem.

Thanks, that works. Thank you for your help, as usual :D Let me know when you figure out why we need to put -b 0.0.0.0.

lcreid commented 5 years ago

It appears that the long argument for binding for rails server is --binding, not --bind. I have no idea why I made that mistake, or if something has changed. At any rate, I've updated the documentation and so I'll close this issue. Thanks for reporting it!

Pacn91 commented 5 years ago

Thank you Icreid. But can you explain me why we can't do rails server only? thks

lcreid commented 5 years ago

I'll try. You laptop or desktop that's hosting the Vagrant box is a separate computer as far as the Vagrant box is concerned. Vagrant does a pretty good job of making that transparent for you.

However, Puma, like most web servers, will only listen to connections coming from the same computer as Puma is running on, by default. (Technically, it listens for connections coming from 127.0.0.1, which by convention is the current computer, aka localhost.) I think that's mostly to prevent you from accidentally exposing the web server to the whole Internet, with all the security concerns that brings with it.

By starting Puma with -b 0.0.0.0 you're telling Puma to accept connections coming from anywhere. (By convention, 0.0.0.0 means "anywhere".) So Puma will now accept connections coming from the host computer, i.e. your laptop or desktop, where the browser is running.

I haven't tried to address this, because I prefer not to put a lot of "magic" on the box. I find that hiding stuff like that can actually make it harder to debug problems, because something is happening that you're not necessarily aware of. That said, if you have ideas about how we could make the developer experience better with this box, I'm all ears.

I hope this helps. Thanks again for your interest in this box.

Pacn91 commented 5 years ago

Humm ok! I appreciate your help and explanation! Very helpful as usual! So there is nothing that I can change to prevent me to put -b 0.0.0.0 everytime I want to launch my rails server?

Other than that, I really like your box. I'm using it on all of my project and I intend to continue to use. Best regards

lcreid commented 5 years ago

You're welcome.

There are things you can do if you really prefer not to have to type -b 0.0.0.0, but they're not things I've done, so I can't send you examples. Sorry. Feel free to open a new issue for this topic, and when I get a chance I'll see if there's something I can do (e.g. add documentation that shows how to do it, or perhaps even come up with a configuration option to add features to the box if someone wants them).

Pacn91 commented 5 years ago

Sorry for being a pain in your ass but I found this and it worked: https://stackoverflow.com/a/55927355/7985922

Just FYI :D Best regards

lcreid commented 5 years ago

You're not being a pain in the ass. It's great to know that someone uses and cares about this gem. I find it very motivating.

Your link is very helpful in terms of how to make this box more usable. Thanks!

Pacn91 commented 5 years ago

You are welcome :)