burke / zeus

Boot any rails app in under a second.
MIT License
3.33k stars 231 forks source link

cannot load such file -- rails/commands/console #634

Closed brancusi closed 7 years ago

brancusi commented 7 years ago

Hi, after upgrading to rails 5, I can no longer run zeus console

I get the following error:

/usr/local/bundle/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `require': cannot load such file -- rails/commands/console (LoadError)
    from /usr/local/bundle/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `block in require'
    from /usr/local/bundle/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:258:in `load_dependency'
    from /usr/local/bundle/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `require'
    from /usr/local/bundle/gems/zeus-0.15.10/lib/zeus/rails.rb:131:in `console'
    from /usr/local/bundle/gems/zeus-0.15.10/lib/zeus.rb:147:in `block in command'
    from /usr/local/bundle/gems/zeus-0.15.10/lib/zeus.rb:134:in `fork'
    from /usr/local/bundle/gems/zeus-0.15.10/lib/zeus.rb:134:in `command'
    from /usr/local/bundle/gems/zeus-0.15.10/lib/zeus.rb:50:in `go'
    from -e:1:in `<main>'

Any ideas?

sideshowcoder commented 7 years ago

Interesting I'm using it with rails 5 at the moment, and it seems to work fine, can you generate a small sample app which experiences this?

brancusi commented 7 years ago

I will try to create one. Thank you

staycreativedesign commented 7 years ago

I am experiencing the same thing as well !! I try to run zeus generate and it gives that exact same error! Rails 5.1.0 ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin15]

staycreativedesign commented 7 years ago

Here is a link to a virgin project hehe :) https://github.com/staycreativedesign/zeus-error

staycreativedesign commented 7 years ago

Works in version 5.02 but not 5.1.0

sideshowcoder commented 7 years ago

Nice thanks so much @staycreativedesign that makes it much easier, I was actually working on a rails 5.0 app I realise. So thanks for that

TangMonk commented 7 years ago

same problem at rails 5.1.1

sideshowcoder commented 7 years ago

Related #569

server-monitor commented 7 years ago

I ran into a similar problem. Instead of console I was trying to run server. I did some digging and here's what I found:

The problem happens in https://github.com/burke/zeus/blob/master/rubygem/lib/zeus/rails.rb at this method:

def server
  require 'rails/commands/server'
  server = ::Rails::Server.new
  Dir.chdir(::Rails.application.root)
  server.start
end

The Rails authors changed the commands directory structure (https://github.com/rails/rails/tree/master/railties/lib/rails/commands). The path for the required file rails/commands/server has been changed to rails/commands/server/server_command.

I edited the method above to reflect this path change:

From: require 'rails/commands/server'

To: require 'rails/commands/server/server_command'

I ran Zeus and a new error appeared: uninitialized constant Rails::Command::Base. I looked around and found the definition of this constant in rails/command. So I inserted require 'rails/command' at the beginning of the method.

I reran Zeus and a new error appeared; rack-2.0.3/lib/rack/server.rb:315:in `exist?': no implicit conversion of nil into String (TypeError).

I have no idea. It seems it has something to do with the injection of options and somehow the Rake task is not receiving those options. And it seems there has been a change in how the Rails server (and possibly the other tasks as well) are setup and invoked.

However, I found a way to make it work from the Rails initialization doc at http://guides.rubyonrails.org/initialization.html.

def server
  require 'rails/command'
  ::Rails::Command.invoke 'server', ARGV
end

I don't know if this is the right way to fix it. It's different from the original pattern. If you want to make the other commands work, you'll have to change the file path to the correct file path (among other things). For example, the method for the console command will have to be changed to something like:

def console
  require 'rails/command'
  require 'rails/commands/console/console_command'    

I hope this helps.

sideshowcoder commented 7 years ago

@server-monitor that helps a lot actually, I think this is very close to getting this fixed, sorry for the late response. Thanks so much for your investigation, if you like I'm very happy to accept a PR to fix that, I'm going to look into it as soon as I have some time to do so.

sideshowcoder commented 7 years ago

See the PR for a rather quick and dirty fix, if somebody likes to try it out that would be great I will built a package to try as soon as I have a Mac handy to build.

sideshowcoder commented 7 years ago

I pushed version 0.15.15.pre to be installable via gem install --pre zeus, make sure to first uninstall versions already on the system via gem uninstall zeus and uninstall all versions including binaries to make sure there is no trouble around that. Would love if someone could try it out.

falonofthetower commented 7 years ago

@sideshowcoder Worked like a charm. I didn't even have to uninstall.

ruby 2.4.1-p111
Rails 5.1.1
zeus 0.15.15.pre
fedora 25
sideshowcoder commented 7 years ago

Yeah for some reason I don't fully understand linux seems to normally be fine without uninstalling while MacOS seems to have trouble with 2 parallel versions of zeus being installed (sometimes). I see the same between my work mac and home ubuntu box. But great that it works @falonofthetower I will release as soon as I get more feedback than 👍

jeremyjs commented 6 years ago

I ran into the same issue using the latest release of zeus with Rails 5.1 and the pre version of zeus is working great for me. Thanks!

sufyanadam commented 6 years ago

Ran into the same issue and the 0.15.15.pre version fixed it. Perhaps it's time for an official release of that version?