Upgrade error: Failed to build gem native extension


(ampburner) #1

Digital Ocean 2Gb ‘cookbook’ install
plugins: spoiler alert, up to date
docker up to date.

trying to upgrade to latest version via control panel.

$ cd /var/www/discourse && git fetch && git reset --hard HEAD@{upstream}
warning: unable to access '/root/.config/git/attributes': Permission denied
warning: unable to access '/root/.config/git/attributes': Permission denied
warning: unable to access '/root/.config/git/attributes': Permission denied
HEAD is now at 96afbd6 TRIVIAL: Don't show 06 Aug, show 6 Aug

********************************************************
*** Please be patient, next steps might take a while ***
********************************************************
$ bundle install --deployment --without test --without development
Fetching source index from https://rubygems.org/
Using rake 10.3.2
Using i18n 0.6.9
Using json 1.8.1
Using minitest 5.3.5
Using thread_safe 0.3.4
Using tzinfo 1.2.1
Using activesupport 4.1.4
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.4
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.4
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.4
Using actionpack-action_caching 1.1.1
Using activemodel 4.1.4
Using active_model_serializers 0.8.1
Using arel 5.0.1.20140414130214
Using activerecord 4.1.4
Using addressable 2.3.6
Using airbrake 3.1.2
Using handlebars-source 1.3.0
Using ember-source 1.6.0.beta.2
Using execjs 2.1.0
Using barber 0.4.2
Using timers 1.1.0
Using celluloid 0.15.2
Using certified 0.1.1
Using coderay 1.1.0
Using connection_pool 2.0.0
Using daemons 1.1.9
Using diff-lcs 1.2.5
Using docile 1.1.3
Using email_reply_parser-discourse 0.6
Using ember-data-source 0.14
Using thor 0.19.1
Using railties 4.1.4
Using jquery-rails 3.1.0
Using ember-rails 0.14.1
Using eventmachine 1.0.3
Using excon 0.37.0
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.0
Using fast_blank 0.0.2
Using rake-compiler 0.9.2
Using fast_stack 0.1.0
Using fast_xor 1.1.3
Using fast_xs 0.8.0
Using fastimage 1.6.0
Using ffi 1.9.3
Using flamegraph 0.0.5
Using formatador 0.2.5
Using net-ssh 2.9.1
Using net-scp 1.2.1
Using fog-core 1.22.0
Using multi_json 1.10.1
Using fog-json 1.0.0
Using inflecto 0.0.2
Using fog-brightbox 0.1.1
Using ipaddress 0.8.0
Using mini_portile 0.6.0
Using nokogiri 1.6.2.1
Using fog 1.22.1
Using fspath 2.0.6
Using sorcerer 1.0.2
Using given_core 3.5.4
Using guess_html_encoding 0.0.9
Using hashie 2.0.5
Using highline 1.6.20
Using hike 1.2.3
Using hiredis 0.5.2
Using htmlentities 4.3.2
Using image_size 1.1.5
Using in_threads 1.2.0
Using progress 3.0.0
Using image_optim 0.9.1
Using jwt 0.1.11
Using kgio 2.9.2
Using libv8 3.16.14.3
Using listen 0.7.3
Using logster 0.1.4
Using lru_redux 0.8.1
Using redis 3.0.7
Using message_bus 0.9.5
Using metaclass 0.0.4
Using method_source 0.8.2
Using mocha 1.0.0
Using mock_redis 0.11.0
Using moneta 0.7.20
Using msgpack 0.5.8
Using multi_xml 0.5.5
Using mustache 0.99.5
Using oauth 0.4.7
Using oauth2 0.9.3

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/local/bin/ruby extconf.rb 
Cannot allocate memory - /usr/local/bin/ruby extconf.rb  2>&1

Gem files will remain installed in /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/oj-2.10.0 for inspection.
Results logged to /var/www/discourse/vendor/bundle/ruby/2.0.0/extensions/x86_64-linux/2.0.0-static/oj-2.10.0/gem_make.out
An error occurred while installing oj (2.10.0), and Bundler cannot continue.
Make sure that `gem install oj -v '2.10.0'` succeeds before bundling.

I have no clue what to do now.


(ampburner) #2

Permission denied errors look similar to


(Jeff Atwood) #3

Cannot allocate memory doesn’t sound good.

  1. What does free -m show on your server?

  2. Did you configure a swap file? Not technically required with a 2GB instance, but never a bad idea… there’s a howto topic here describing how to do it.


(ampburner) #4

result of free -m

             total       used       free     shared    buffers     cached
Mem:          2001       1847        154        119         24        290
-/+ buffers/cache:       1532        469
Swap:            0          0          0

ah, I guess that doesn’t look good…

Processes tab

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
discour+ 24638  1.4 13.3 1096480 274696 ?      Sl   Aug09 208:42 unicorn worker[0] -E production -c config/unicorn.conf.rb                                           
discour+ 24645  1.4 13.2 1096480 271392 ?      Sl   Aug09 207:55 unicorn worker[1] -E production -c config/unicorn.conf.rb                                           
discour+ 24650  1.3 13.2 1089312 271240 ?      Sl   Aug09 207:31 unicorn worker[2] -E production -c config/unicorn.conf.rb                                           
discour+ 24613  0.3 12.6 1276168 258532 ?      Sl   Aug09  57:55 sidekiq 3.1.3 discourse [0 of 5 busy]                                                               
discour+ 24564  0.0  9.6 452656 198612 ?       Sl   Aug09   2:04 unicorn master -E production -c config/unicorn.conf.rb                                              
postgres    54  0.0  5.5 248196 113684 ?       Ss   Jul03   6:41 postgres: checkpointer process                                    
redis       40  0.4  5.0 148884 103928 ?       Sl   Jul03 276:47 /usr/bin/redis-server *:6379               
postgres 24654  0.1  4.9 294312 101232 ?       Ss   Aug09  16:53 postgres: discourse discourse [local] idle                        
postgres 24720  0.1  4.8 292100 100012 ?       Ss   Aug09  16:59 postgres: discourse discourse [local] idle                        
postgres 24810  0.1  4.8 291696 99092 ?        Ss   Aug09  16:54 postgres: discourse discourse [local] idle                        
postgres 24657  0.1  4.8 291960 98992 ?        Ss   Aug09  16:55 postgres: discourse discourse [local] idle                        
postgres 24883  0.1  4.8 292192 98752 ?        Ss   Aug09  16:47 postgres: discourse discourse [local] idle                        
postgres 24642  0.1  4.7 290064 98332 ?        Ss   Aug09  16:50 postgres: discourse discourse [local] idle                        
postgres  8082  0.0  4.2 287556 87208 ?        Ss   Aug09   0:58 postgres: discourse discourse [local] idle                        
postgres 24622  0.0  4.1 287628 84216 ?        Ss   Aug09   0:59 postgres: discourse discourse [local] idle                        
postgres  8079  0.0  4.0 289072 84040 ?        Ss   Aug09   0:59 postgres: discourse discourse [local] idle                        
postgres  3320  0.0  4.0 287440 82792 ?        Ss   Aug09   1:02 postgres: discourse discourse [local] idle                        
postgres 31322  0.0  4.0 286164 82220 ?        Ss   Aug09   1:00 postgres: discourse discourse [local] idle                        
postgres    39  0.0  0.6 247952 13032 ?        S    Jul03   2:30 /usr/lib/postgresql/9.3/bin/postmaster -D /etc/postgresql/9.3/main
syslog      25  0.0  0.5 182304 11680 ?        Sl   Jul03   0:16 rsyslogd -n
postgres    56  0.0  0.2 247952  5720 ?        Ss   Jul03   1:12 postgres: wal writer process                                      
www-data    50  0.0  0.1  91576  3156 ?        S    Jul03  35:55 nginx: worker process
www-data    52  0.0  0.1  91580  3148 ?        S    Jul03  35:24 nginx: worker process
postgres    57  0.0  0.1 248748  2976 ?        Ss   Jul03   1:53 postgres: autovacuum launcher process                             
www-data    51  0.0  0.1  91280  2876 ?        S    Jul03  35:40 nginx: worker process
www-data    49  0.0  0.1  91096  2712 ?        S    Jul03  35:17 nginx: worker process
postgres    55  0.0  0.1 247952  2588 ?        Ss   Jul03   1:08 postgres: writer process                                          
discour+    47  0.1  0.1  30784  2380 ?        S    Jul03  77:01 /bin/bash config/unicorn_launcher -E production -c config/unicorn.conf.rb
root        31  0.0  0.1  90268  2128 ?        S    Jul03   0:00 nginx: master process /usr/sbin/nginx
postgres    58  0.0  0.0 103772  1876 ?        Ss   Jul03   8:01 postgres: stats collector process                                 
discour+ 27305  0.0  0.0  31020  1536 ?        R    19:29   0:00 ps aux --sort -rss
root        28  0.0  0.0  61364  1452 ?        S    Jul03   0:00 /usr/sbin/sshd -D -e
root        14  0.0  0.0  21096  1080 ?        Ss   Jul03   0:00 /bin/bash /etc/runit/2
root        29  0.0  0.0  50220   996 ?        S    Jul03   0:00 sudo -E -u discourse LD_PRELOAD=/usr/lib/libjemalloc.so.1 bundle exec config/unicorn_launcher -E production -c config/unicorn.conf.rb
root        30  0.0  0.0  50220   996 ?        S    Jul03   0:00 sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf
root        27  0.0  0.0  50220   992 ?        S    Jul03   0:00 sudo -u postgres /usr/lib/postgresql/9.3/bin/postmaster -D /etc/postgresql/9.3/main
root        26  0.0  0.0  26744   864 ?        S    Jul03   0:12 cron -f
discour+ 27304  0.0  0.0  20036   824 ?        S    19:29   0:00 sleep 1
root        24  0.0  0.0   7436   608 ?        S    Jul03   0:00 sleep 2147483647
root        15  0.0  0.0    188    36 ?        S    Jul03   1:44 /usr/bin/runsvdir -P /etc/service
root         1  0.0  0.0    160     4 ?        Ss+  Jul03   0:46 /sbin/runit
root        16  0.0  0.0    168     4 ?        Ss   Jul03   0:00 runsv copy_env
root        17  0.0  0.0    168     4 ?        Ss   Jul03   0:00 runsv rsyslog
root        18  0.0  0.0    168     4 ?        Ss   Jul03   0:00 runsv cron
root        19  0.0  0.0    168     4 ?        Ss   Jul03   0:00 runsv unicorn
root        20  0.0  0.0    168     4 ?        Ss   Jul03   0:00 runsv sshd
root        21  0.0  0.0    168     4 ?        Ss   Jul03   0:00 runsv redis
root        22  0.0  0.0    168     4 ?        Ss   Jul03   0:00 runsv nginx
root        23  0.0  0.0    168     4 ?        Ss   Jul03   0:00 runsv postgres

no swap file.


(Jeff Atwood) #5

My guess is you’re getting enough load to run into memory issues. Upgrading does, unfortunately, push a lot of memory around for kind of arbitrary reasons.

Go ahead and create a 2GB swapfile and you should be better, upgrades won’t fail.


(ampburner) #6

cool I’ll give this a try:


(ampburner) #7

Thanks Jeff! that did it :smile: