I just tried to do a restore on a web_only container and it whines that it can’t load thor when it tries to load_rails. (If you don’t actually try to restore, it doesn’t fail --and OMG, how awesome is it that it suggests filenames and you can then copy and paste from a list!!! I don’t know how long that’s been there, but I was psyched to find it.)
root@web-only:/var/www/discourse# script/discourse restore ning-import-2017-08-22-172513-v20170803123704.tar.gz
/usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- thor (LoadError)
from /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from script/discourse:3:in `<main>'
So if you run discourse restore with no arguments, it prints something like this:
You must provide a filename to restore. Did you mean one of the following?
script/discourse restore ipb-import-2017-08-23-165728-v20170605014820.tar.gz
script/discourse restore ipb-import-2017-08-22-180715-v20170605014820.tar.gz
And then if you copy-paste on of those, it runs script/discourse rather tahn discourse, and that doesn’t work.
And I was so excited about the “copy this line” feature.
I think it would be better if we figure out what the current path is and suggest the appropriate command. Running script/discourse is right if I’m in the /var/www/discourse directory.
Have you done that recently? That’s where I discovered this problem, and why I started the thread. This is for enable_restore, but it’s the same can’t-load-rails problem.
root@discourse:~# cd /var/discourse/
root@discourse:/var/discourse# ./launcher enter app
root@discourse:/var/www/discourse# discourse enable_restore
Expected string default value for '--verbose'; got false (boolean)
Restore are now permitted. Disable them with `disable_restore`
root@discourse:/var/www/discourse# script/discourse enable_restore
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:317:in `check_for_activated_spec!': You have already activated thor 0.20.0, but your Gemfile requires thor 0.19.4. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:32:in `block in setup'
from /usr/local/lib/ruby/2.3.0/forwardable.rb:204:in `each'
from /usr/local/lib/ruby/2.3.0/forwardable.rb:204:in `each'
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:27:in `map'
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:27:in `setup'
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler.rb:101:in `setup'
from /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/setup.rb:9:in `<top (required)>'
from /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
from /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
from /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from /var/www/discourse/config/boot.rb:11:in `<top (required)>'
from /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/www/discourse/config/application.rb:1:in `<top (required)>'
from /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/www/discourse/config/environment.rb:2:in `<top (required)>'
from /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from script/discourse:221:in `load_rails'
from script/discourse:137:in `enable_restore'
from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from /usr/local/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
from script/discourse:262:in `<main>'
root@discourse:/var/www/discourse#
bundle exec script/discourse is the solution here. The second problem is because you were running bundle exec script/discourse while you were in /var/www/discourse/script instead of /var/www/discourse.
So I guess that script/discourse works in a development environment and the discourse wrapper works in production? Is there a way for the script to tell?
And, really, this is a fringe feature that tens of people will probably ever use.
In production, running discourse instead of script/discourse works.