Restore backup : error Thor

AI-generated summary

A user attempted to restore a backup using the command line but encountered an error due to the missing Thor gem. tgxworld suggested installing the Thor gem manually using gem install thor. However, users Chopper and eviltrout questioned why the Thor gem is not installed by default, as it is required for CLI backups. Mittineague pointed out that the Thor gem is listed in the Gemfile.lock, but Chopper reported that the gem is not installed on a fresh install. sam agreed that expecting users to install gems manually is unreasonable. A potential fix was proposed by eviltrout, but michaeld warned that Thor versions beyond 0.19.1 can cause issues. A possible solution is to install the Thor gem when the backup button is clicked and remove it afterwards to avoid version conflicts.

I tried to restore a backup with command line (GUI is not an option) but I get this error :

root@forum:/var/discourse# ./launcher enter app
root@forum-app:/var/www/discourse# discourse restore
You must provide a filename to restore. Did you mean one of the following?

script/discourse restore tact-forum-2017-02-01-075306-v20161216101352.tar.gz
root@forum-app:/var/www/discourse# script/discourse restore tact-forum-2017-02-01-075306-v20161216101352.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>'

@zogstrip can you have a look?

Seems my docker is broken. Is there a way to quickly check if someting went wrong in the docker ?

The Thor gem isn’t installed by default.

From your container run gem install thor and you should be good to go.

Why the gem thor is not installed by default since he is used to do the backup ?

There is a GUI to restore a backup but an admin need to go on the docker to install the gem and then restore the backup ? :unamused:

I’ve actually wondered this for a while. If thor is needed for our CLI surely it should be installed in the Gemfile.

It is in the lock

I have this file too, but obviously the gem are not installed

root@ubuntu-app:/var/www/discourse# gem list

*** LOCAL GEMS ***

bigdecimal (1.2.8)
bundler (1.14.5, 1.13.7)
did_you_mean (1.0.0)
io-console (0.4.5)
json (1.8.3)
minitest (5.8.5)
net-telnet (0.1.1)
power_assert (0.2.6)
psych (2.1.0)
rake (10.4.2)
rdoc (4.2.1)
test-unit (3.1.5)

This is a fresh install, the lastest version of discourse downloaded this morning.

Maybe it is only installed in dev mode, agree we should fix this, expecting people to install gems just to get discourse CLI to run is crazy

I think this will fix it:

https://github.com/discourse/discourse/commit/890f1bde894239a86da49908a31aa5e0a33072f5

Be careful, I remember that a thor version beyond 0.19.1 breaks stuff in ugly ways.

Or the gem should be installed when backup button is clicked and removed after regarding what @michaeld says

Really? Whenever I encountered the error I’d type gem install thor on the command line to get the latest version and it’s always worked. Do you have steps to reproduce it?

Sorry, can’t find it in my notes :frowning: