How can I run the importer in “development mode”?
The MyBB forum runs on a separate machine. I cloned the Discourse repo on that machine, changed the MySQL login details in mybb.rb
and tried to run RAILS_ENV=production bundle exec ruby script/import_scripts/mybb.rb
. It failed with:
/home/dan/discourse/Gemfile:92:in `evaluate': compile error (SyntaxError)
/home/dan/discourse/Gemfile:72: syntax error, unexpected ':', expecting kEND
gem 'arel', git: 'https://github.com/rails/arel.git'
^
/home/dan/discourse/Gemfile:73: syntax error, unexpected ':', expecting kEND
gem 'rails', git: 'https://github.com/rails/rails.git'
^
/home/dan/discourse/Gemfile:74: syntax error, unexpected ':', expecting kEND
gem 'rails-observers', git: 'https://github.com/SamSaffro...
^
/home/dan/discourse/Gemfile:75: syntax error, unexpected ':', expecting kEND
gem 'seed-fu', git: 'https://github.com/SamSaffro...
^
/home/dan/discourse/Gemfile:75: syntax error, unexpected ',', expecting kEND
...b.com/SamSaffron/seed-fu.git', branch: 'discourse'
^
/home/dan/discourse/Gemfile:92: syntax error, unexpected ':', expecting $end
gem 'redis', require: ["redis", "redis/connection/hiredis"]
^
from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:17:in `build'
from /usr/lib/ruby/vendor_ruby/bundler.rb:136:in `definition'
from /usr/lib/ruby/vendor_ruby/bundler.rb:124:in `load'
from /usr/lib/ruby/vendor_ruby/bundler.rb:107:in `setup'
from /usr/lib/ruby/vendor_ruby/bundler/cli.rb:342:in `exec'
from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/task.rb:22:in `send'
from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/task.rb:22:in `run'
from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor.rb:246:in `dispatch'
from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/base.rb:389:in `start'
from /usr/bin/bundle:13
These syntax errors suggest that bundle
was the wrong executable. I ran sudo gem install bundler
, which fixed the problem. Then,
RAILS_ENV=production bundle exec ruby script/import_scripts/mybb.rb
Could not find pg-0.18.1 in any of the sources
Run `bundle install` to install missing gems.
Alright,
$ bundle install
Fetching gem metadata from https://rubygems.org/.......
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Using rake 10.4.2
Using CFPropertyList 2.2.8
Using i18n 0.7.0
Using json 1.8.2
Using minitest 5.5.1
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.1.9
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.9
Using rack 1.5.2
Using rack-test 0.6.3
Using actionpack 4.1.9
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.9
Using actionpack-action_caching 1.1.1
Using activemodel 4.1.9
Using active_model_serializers 0.8.2
Using arel 5.0.1.20140414130214
Using activerecord 4.1.9
Using annotate 2.6.6
Using babel-source 4.6.6
Using execjs 2.4.0
Using babel-transpiler 0.6.0
Using handlebars-source 2.0.0
Using ember-source 1.9.0.beta.4
Using barber 0.5.0
Using coderay 1.1.0
Using better_errors 2.1.1
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using hitimes 1.2.2
Using timers 4.0.1
Using celluloid 0.16.0
Using certified 1.0.0
Using connection_pool 2.1.2
Using crass 1.0.1
Using daemons 1.1.9
Using diff-lcs 1.2.5
Using docile 1.1.5
Using dotenv 1.0.2
Using email_reply_parser 0.5.8
Using ember-data-source 0.14
Using thor 0.19.1
Using railties 4.1.9
Using jquery-rails 3.1.2
Using ember-rails 0.14.1
Using eventmachine 1.0.7
Using excon 0.44.4
Using exifr 1.1.3
Using fabrication 2.9.8
Using fakeweb 1.3.0
Using multipart-post 2.0.0
Using faraday 0.9.1
Using fast_blank 0.0.2
Using rake-compiler 0.9.4
Using fast_stack 0.1.0
Using fast_xor 1.1.3
Using fast_xs 0.8.0
Using fastimage_discourse 1.6.6
Using ffi 1.9.6
Using fission 0.5.0
Using flamegraph 0.1.0
Using formatador 0.2.5
Using net-ssh 2.9.2
Using net-scp 1.2.1
Using fog-core 1.27.2
Using mini_portile 0.6.2
Using nokogiri 1.6.6.2
Using fog-xml 0.1.1
Using fog-atmos 0.1.0
Using multi_json 1.10.1
Using fog-json 1.0.0
Using inflecto 0.0.2
Using fog-brightbox 0.7.1
Using fog-ecloud 0.0.2
Using fog-profitbricks 0.0.1
Using fog-radosgw 0.0.3
Using fog-sakuracloud 0.1.1
Using fog-softlayer 0.3.26
Using fog-storm_on_demand 0.1.0
Using fog-terremark 0.0.3
Using fog-vmfusion 0.0.1
Using fog-voxel 0.0.2
Using ipaddress 0.8.0
Using fog 1.26.0
Using foreman 0.77.0
Using fspath 2.0.6
Using sorcerer 1.0.2
Using given_core 3.5.4
Using guess_html_encoding 0.0.11
Using hashie 3.4.0
Using highline 1.7.1
Using hike 1.2.3
Using hiredis 0.6.0
Using htmlentities 4.3.3
Using image_size 1.1.5
Using in_threads 1.2.2
Using progress 3.0.2
Using image_optim 0.9.1
Using jwt 1.3.0
Using kgio 2.9.3
Using librarian 0.1.2
Using libv8 3.16.14.7
Using listen 0.7.3
Using logster 0.1.8
Using lru_redux 0.8.4
Using redis 3.2.1
Using message_bus 1.0.6
Using metaclass 0.0.4
Using method_source 0.8.2
Using mocha 1.1.0
Using mock_redis 0.14.0
Using moneta 0.8.0
Using msgpack 0.5.11
Using multi_xml 0.5.5
Using mustache 0.99.8
Using netrc 0.10.3
Using nokogumbo 1.2.0
Using oauth 0.4.7
Using oauth2 1.0.0
Using oj 2.12.0
Using omniauth 1.2.2
Using omniauth-oauth2 1.2.0
Using omniauth-facebook 2.0.0
Using omniauth-github-discourse 1.1.2
Using omniauth-google-oauth2 0.2.5
Using omniauth-oauth 1.0.1
Using ruby-openid 2.5.0
Using rack-openid 1.3.1
Using omniauth-openid 1.0.1
Using omniauth-twitter 1.0.1
Using onebox 1.5.13
Using openid-redis-store 0.0.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby -r ./siteconf20150312-9260-1dzgbkw.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
extconf failed, exit code 1
Gem files will remain installed in /tmp/bundler20150312-9260-osxjxp/pg-0.18.1/gems/pg-0.18.1 for inspection.
Results logged to /tmp/bundler20150312-9260-osxjxp/pg-0.18.1/extensions/x86_64-linux/2.2.0-static/pg-0.18.1/gem_make.out
An error occurred while installing pg (0.18.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.1'` succeeds before bundling.
Stuck.
I also tried the second option you mentioned, but couldn’t install the mysql2
gem:
root@li895-63-app:~# su - discourse
discourse@li895-63-app:~$ gem install mysql2
Fetching: mysql2-0.3.18.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/local/lib/ruby/gems/2.0.0 directory.
Exited the su
and tried to install it as root:
root@localhost:/var/discourse# ./launcher ssh app
WARNING: No memory limit support
WARNING: No swap limit support
lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
Welcome to Discourse Docker
Use: rails, rake or discourse to execute commands in production
root@li895-63-app:~# gem install mysql2
Fetching: mysql2-0.3.18.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby -r ./siteconf20150312-1794-3xmznr.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/
--with-mysql-config
--without-mysql-config
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/
--with-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib
extconf failed, exit code 1
Gem files will remain installed in /usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.18 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.0.0/extensions/x86_64-linux/2.0.0-static/mysql2-0.3.18/gem_make.out
root@li895-63-app:~#
Rails is known to be hard to install, and Ruby is part of that problem. This is makes the migration process quite painful and a traumatic experience for new users. How can we improve this? Are the some streamlined guidelines on importing data from other forums that I’ve missed?
This doesn’t only apply to MyBB. Running any migration script needs to get all these dependencies installed, and I’ve been running into errors after errors.