'Send invoice' and 'print invoice' buttons are not working with the Spree Upgrade
This was first spotted here - https://community.openfoodnetwork.org/t/spree-testing-june-2017/976
It continues to be a problem as at June 21st 2017

We tried again and it works in our local machines. I'm pretty sure the issue is that we're missing a MailMethod in that staging. @oeoeaio can you please tell us what this returns when executed in the rails console?
MailMethod.all
We should have at least one mail method set up.
Sorry I did not see this earlier. I looked through the Bugsnag logs and there is a record that points to an issue with permission to access wkhtmltopdf. Looks like unicorn was running in a weird environment, causing a permission problem. This should be resolved now.
There is definitely a mail_method there.
ruby
irb> Spree::MailMethod.all
[#<Spree::MailMethod id: 1, environment: "staging", active: true, created_at: "2012-07-19 22:51:20", updated_at: "2013-12-16 07:38:04">]
@sstead can you take a look know? I'm pretty sure this is a false alarm.
@sauloperez the Authorisation Failure error is still occuring :(
I just tested 1693 and it is fixed. But this error remains.
:see_no_evil: I hate these issues that work in dev and don't in staging...
From staging log:
RuntimeError (Bad wkhtmltopdf's path: `/` is not writable.
Bundler will use `/tmp/bundler/home/unknown' as your home directory temporarily.
/home/openfoodweb/.gem/ruby/2.1.0/bin/wkhtmltopdf):
app/controllers/spree/admin/orders_controller_decorator.rb:80:in `invoice'
The root cause is that when we load our wicked_pdf initializer in staging environment Bundler returns that weird error and we pass it along as if it was a path...
https://github.com/openfoodfoundation/openfoodnetwork/blob/master/config/initializers/wicked_pdf.rb#L4
Seems to be related to this issue: https://github.com/bundler/bundler/issues/5371. At least the error message is the same.
Looks like the https://github.com/openfoodfoundation/ofn-install/blob/master/roles/webserver/templates/unicorn_init.j2 is broken. When executing it ENV contains:
{"RBENV_VERSION"=>"2.1.5", "TERM"=>"xterm-256color", "RBENV_ROOT"=>"/home/openfoodweb/.rbenv", "RBENV_HOOK_PATH"=>":/home/openfoodweb/.rbenv/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks:/home/openfoodweb/.rbenv/plugins/rbenv-default-gems/etc/rbenv.d:/home/open
foodweb/.rbenv/plugins/rbenv-vars/etc/rbenv.d", "PATH"=>"/home/openfoodweb/.rbenv/versions/2.1.5/bin:/home/openfoodweb/.rbenv/libexec:/home/
openfoodweb/.rbenv/plugins/rbenv-bootstrap/bin:/home/openfoodweb/.rbenv/plugins/rbenv-installer/bin:/home/openfoodweb/.rbenv/plugins/rbenv-u
pdate/bin:/home/openfoodweb/.rbenv/plugins/rbenv-use/bin:/home/openfoodweb/.rbenv/plugins/rbenv-vars/bin:/home/openfoodweb/.rbenv/plugins/rb
env-whatis/bin:/home/openfoodweb/.rbenv/plugins/ruby-build/bin:/home/openfoodweb/.rbenv/shims:/home/openfoodweb/.rbenv/bin:/home/openfoodweb
/.rbenv/shims:/home/openfoodweb/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games", "PWD"=>"/home/openfoodw
eb/apps/openfoodweb/current", "LANG"=>"en_AU.UTF-8", "SHLVL"=>"0", "RBENV_DIR"=>"/home/openfoodweb/apps/openfoodweb/current", "GEM_PATH"=>":/.gems"}
When executing RAILS_ENV=staging bundle exec rails s instead:
{"RBENV_VERSION"=>"2.1.5", "LC_PAPER"=>"es_ES.UTF-8", "LC_ADDRESS"=>"es_ES.UTF-8", "LC_MONETARY"=>"es_ES.UTF-8", "SHELL"=>"/bin/bash", "TERM"=>"xterm-256color", "SSH_CLIENT"=>"95.61.26.58 57232 22", "LC_NUMERIC"=>"es_ES.UTF-8", "SSH_TTY"=>"/dev/pts/1", "LC_ALL"=>"en_AU.UTF-8", "USER"=>"openfoodweb", "LC_TELEPHONE"=>"es_ES.UTF-8", "LS_COLORS"=>"rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:", "RBENV_ROOT"=>"/home/openfoodweb/.rbenv", "SSH_AUTH_SOCK"=>"/tmp/ssh-Kfguq10126/agent.10126", "RBENV_HOOK_PATH"=>":/home/openfoodweb/.rbenv/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks:/home/openfoodweb/.rbenv/plugins/rbenv-default-gems/etc/rbenv.d:/home/openfoodweb/.rbenv/plugins/rbenv-vars/etc/rbenv.d", "PATH"=>"/home/openfoodweb/.rbenv/versions/2.1.5/bin:/home/openfoodweb/.rbenv/libexec:/home/openfoodweb/.rbenv/plugins/rbenv-bootstrap/bin:/home/openfoodweb/.rbenv/plugins/rbenv-installer/bin:/home/openfoodweb/.rbenv/plugins/rbenv-update/bin:/home/openfoodweb/.rbenv/plugins/rbenv-use/bin:/home/openfoodweb/.rbenv/plugins/rbenv-vars/bin:/home/openfoodweb/.rbenv/plugins/rbenv-whatis/bin:/home/openfoodweb/.rbenv/plugins/ruby-build/bin:/home/openfoodweb/.rbenv/shims:/home/openfoodweb/.rbenv/bin:/home/openfoodweb/.rbenv/shims:/home/openfoodwe
b/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games", "MAIL"=>"/var/mail/openfoodweb", "LC_IDENTIFICATION"=
>"es_ES.UTF-8", "PWD"=>"/home/openfoodweb/apps/openfoodweb/current", "LANG"=>"en_AU.UTF-8", "LC_MEASUREMENT"=>"es_ES.UTF-8", "NODE_PATH"=>"/
usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript", "HOME"=>"/home/openfoodweb", "SHLVL"=>"1", "LANGUAGE"=>"en_AU:en", "RAILS_ENV"=
>"staging", "RBENV_DIR"=>"/home/openfoodweb/apps/openfoodweb/current", "LOGNAME"=>"openfoodweb", "GEM_PATH"=>":/home/openfoodweb/.gems", "SS
H_CONNECTION"=>"95.61.26.58 57232 111.67.19.119 22", "LESSOPEN"=>"| /usr/bin/lesspipe %s", "LC_TIME"=>"es_ES.UTF-8", "LESSCLOSE"=>"/usr/bin/lesspipe %s %s", "LC_NAME"=>"es_ES.UTF-8"}
Since when booting the app through init.d HOME is not defined ruby defaults to / as defined in https://github.com/rubygems/rubygems/blob/master/lib/rubygems.rb#L595, causing operations that write to $HOME fail.
cc @mkllnk @oeoeaio @Matt-Yorkley
It doesn't seem something related to Spree upgrade, maybe we should try to deploy step 6 branch to another staging server and give it a try.
I just had a long chat with Enrico about this and I looked into the configuration of our staging and production servers. It seems like this is a server issue happening on both of our staging servers independent of the Spree upgrade. Our production server runs some different versions of software and has a different configuration as well.
I will take this issue out of the Spree milestone, but we need to fix our servers to enable proper testing. It would be best to re-install the servers to have them all running in the same environment. Only then we can be sure that code that runs on staging, will actually work on production as well.
Enrico actually said that he is not confident merging the Spree upgrade into master if we a) can't test properly and b) our production server might be different and may have issues with the code we couldn't test before. We don't have any other server running the same old configuration as our production server.
I just added the following line to the init script:
export HOME=/home/openfoodweb
That fixed it on staging2. Does that need to go into ofn-install?
:scream: I'm not sure. Shouldn't this be out of the box if we run the provisioning with the user openfoodnetwork? @danypr92 and @enricostano will tell you.
Shouldn't this be out of the box
Yes it should be.
@mkllnk what was the value of HOME before the export?
@enricostano Good question. I didn't check at the time, but just testing now HOME is already set to the right value /home/openfoodweb. So I don't know what caused this error in the first place.
@sstead @mkllnk is this bug still possible to reproduce? If not please close this issue and feel free to reopen it if it happens again. I suspect it was an environment issue.
Most helpful comment
@sstead @mkllnk is this bug still possible to reproduce? If not please close this issue and feel free to reopen it if it happens again. I suspect it was an environment issue.